-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Change FileScanConfig.table_partition_cols from (String, DataType) to Fields
#7890
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b928ee5
feat: make data type of FileScanConfig.table_partition_cols a vector …
NGA-TRAN 71b240a
fix: avro test
NGA-TRAN f78ebf9
chore: Apply suggestions from code review
NGA-TRAN 62f3700
chore: address review comments
NGA-TRAN 540ff94
chore: remove uncessary to_owned
NGA-TRAN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,7 @@ pub struct FileScanConfig { | |
| /// all records after filtering are returned. | ||
| pub limit: Option<usize>, | ||
| /// The partitioning columns | ||
| pub table_partition_cols: Vec<(String, DataType)>, | ||
| pub table_partition_cols: Vec<Field>, | ||
| /// All equivalent lexicographical orderings that describe the schema. | ||
| pub output_ordering: Vec<LexOrdering>, | ||
| /// Indicates whether this plan may produce an infinite stream of records. | ||
|
|
@@ -135,8 +135,7 @@ impl FileScanConfig { | |
| table_cols_stats.push(self.statistics.column_statistics[idx].clone()) | ||
| } else { | ||
| let partition_idx = idx - self.file_schema.fields().len(); | ||
| let (name, dtype) = &self.table_partition_cols[partition_idx]; | ||
| table_fields.push(Field::new(name, dtype.to_owned(), false)); | ||
| table_fields.push(self.table_partition_cols[partition_idx].to_owned()); | ||
|
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. And this where we convert |
||
| // TODO provide accurate stat for partition column (#1186) | ||
| table_cols_stats.push(ColumnStatistics::new_unknown()) | ||
| } | ||
|
|
@@ -501,10 +500,10 @@ mod tests { | |
| Arc::clone(&file_schema), | ||
| None, | ||
| Statistics::new_unknown(&file_schema), | ||
| vec![( | ||
| to_partition_cols(vec![( | ||
| "date".to_owned(), | ||
| wrap_partition_type_in_dict(DataType::Utf8), | ||
| )], | ||
| )]), | ||
| ); | ||
|
|
||
| let (proj_schema, proj_statistics, _) = conf.project(); | ||
|
|
@@ -527,6 +526,35 @@ mod tests { | |
| assert_eq!(col_indices, None); | ||
| } | ||
|
|
||
| #[test] | ||
| fn physical_plan_config_no_projection_tab_cols_as_field() { | ||
| let file_schema = aggr_test_schema(); | ||
|
|
||
| // make a table_partition_col as a field | ||
| let table_partition_col = | ||
| Field::new("date", wrap_partition_type_in_dict(DataType::Utf8), true) | ||
| .with_metadata(HashMap::from_iter(vec![( | ||
| "key_whatever".to_owned(), | ||
| "value_whatever".to_owned(), | ||
| )])); | ||
|
|
||
| let conf = config_for_projection( | ||
| Arc::clone(&file_schema), | ||
| None, | ||
| Statistics::new_unknown(&file_schema), | ||
| vec![table_partition_col.clone()], | ||
| ); | ||
|
|
||
| // verify the proj_schema inlcudes the last column and exactly the same the field it is defined | ||
| let (proj_schema, _proj_statistics, _) = conf.project(); | ||
| assert_eq!(proj_schema.fields().len(), file_schema.fields().len() + 1); | ||
| assert_eq!( | ||
| *proj_schema.field(file_schema.fields().len()), | ||
| table_partition_col, | ||
| "partition columns are the last columns and ust have all values defined in created field" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn physical_plan_config_with_projection() { | ||
| let file_schema = aggr_test_schema(); | ||
|
|
@@ -545,10 +573,10 @@ mod tests { | |
| .collect(), | ||
| total_byte_size: Precision::Absent, | ||
| }, | ||
| vec![( | ||
| to_partition_cols(vec![( | ||
| "date".to_owned(), | ||
| wrap_partition_type_in_dict(DataType::Utf8), | ||
| )], | ||
| )]), | ||
| ); | ||
|
|
||
| let (proj_schema, proj_statistics, _) = conf.project(); | ||
|
|
@@ -602,7 +630,7 @@ mod tests { | |
| file_batch.schema().fields().len() + 2, | ||
| ]), | ||
| Statistics::new_unknown(&file_batch.schema()), | ||
| partition_cols.clone(), | ||
| to_partition_cols(partition_cols.clone()), | ||
| ); | ||
| let (proj_schema, ..) = conf.project(); | ||
| // created a projector for that projected schema | ||
|
|
@@ -747,7 +775,7 @@ mod tests { | |
| file_schema: SchemaRef, | ||
| projection: Option<Vec<usize>>, | ||
| statistics: Statistics, | ||
| table_partition_cols: Vec<(String, DataType)>, | ||
| table_partition_cols: Vec<Field>, | ||
| ) -> FileScanConfig { | ||
| FileScanConfig { | ||
| file_schema, | ||
|
|
@@ -762,6 +790,14 @@ mod tests { | |
| } | ||
| } | ||
|
|
||
| /// Convert partition columns from Vec<String DataType> to Vec<Field> | ||
| fn to_partition_cols(table_partition_cols: Vec<(String, DataType)>) -> Vec<Field> { | ||
| table_partition_cols | ||
| .iter() | ||
| .map(|(name, dtype)| Field::new(name, dtype.clone(), false)) | ||
| .collect::<Vec<_>>() | ||
| } | ||
|
|
||
| /// returns record batch with 3 columns of i32 in memory | ||
| pub fn build_table_i32( | ||
| a: (&str, &Vec<i32>), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Here is the key change
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.
You probably want to use FieldRef not Field