Skip to content

Apache DataFusion SQL Query Engine

Make `ListingTableUrl::try_new` public (#15250)

Heran Line4bf9512616c
diff --git a/datafusion/datasource/src/url.rs b/datafusion/datasource/src/url.rs
index 89e73a8a2b..0667a043e2 100644
--- a/datafusion/datasource/src/url.rs
+++ b/datafusion/datasource/src/url.rs
@@ -136,7 +136,12 @@ impl ListingTableUrl {
}
/// Creates a new [`ListingTableUrl`] from a url and optional glob expression
- fn try_new(url: Url, glob: Option<Pattern>) -> Result<Self> {
+ ///
+ /// [`Self::parse`] supports glob expression only for file system paths.
+ /// However, some applications may want to support glob expression for URLs with a scheme.
+ /// The application can split the URL into a base URL and a glob expression and use this method
+ /// to create a [`ListingTableUrl`].
+ pub fn try_new(url: Url, glob: Option<Pattern>) -> Result<Self> {
let prefix = Path::from_url_path(url.path())?;
Ok(Self { url, prefix, glob })
}