-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Improvements to list_files_cache table function
#19703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,9 +161,7 @@ impl TableProviderFactory for ListingTableFactory { | |
| } | ||
| None => format!("*.{}", cmd.file_type.to_lowercase()), | ||
| }; | ||
| table_path = table_path | ||
| .with_glob(glob.as_ref())? | ||
| .with_table_ref(cmd.name.clone()); | ||
| table_path = table_path.with_glob(glob.as_ref())?; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be simplified due to the change in |
||
| } | ||
| let schema = options.infer_schema(session_state, &table_path).await?; | ||
| let df_schema = Arc::clone(&schema).to_dfschema()?; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,7 +42,7 @@ pub struct ListingTableUrl { | |||||||||||||||||||
| prefix: Path, | ||||||||||||||||||||
| /// An optional glob expression used to filter files | ||||||||||||||||||||
| glob: Option<Pattern>, | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /// Optional table reference for the table this url belongs to | ||||||||||||||||||||
| table_ref: Option<TableReference>, | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -340,17 +340,19 @@ impl ListingTableUrl { | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /// Returns a copy of current [`ListingTableUrl`] with a specified `glob` | ||||||||||||||||||||
| pub fn with_glob(self, glob: &str) -> Result<Self> { | ||||||||||||||||||||
| let glob = | ||||||||||||||||||||
| Pattern::new(glob).map_err(|e| DataFusionError::External(Box::new(e)))?; | ||||||||||||||||||||
| Self::try_new(self.url, Some(glob)) | ||||||||||||||||||||
| pub fn with_glob(mut self, glob: &str) -> Result<Self> { | ||||||||||||||||||||
| self.glob = | ||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to call the constructor again as datafusion/datafusion/datasource/src/url.rs Lines 149 to 157 in 8a9bf43
This then simplifies the code in |
||||||||||||||||||||
| Some(Pattern::new(glob).map_err(|e| DataFusionError::External(Box::new(e)))?); | ||||||||||||||||||||
| Ok(self) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /// Set the table reference for this [`ListingTableUrl`] | ||||||||||||||||||||
| pub fn with_table_ref(mut self, table_ref: TableReference) -> Self { | ||||||||||||||||||||
| self.table_ref = Some(table_ref); | ||||||||||||||||||||
| self | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /// Return the table reference for this [`ListingTableUrl`] | ||||||||||||||||||||
| pub fn get_table_ref(&self) -> &Option<TableReference> { | ||||||||||||||||||||
| &self.table_ref | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses
NULL(rather than"NULL") inlist_files_cache