You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "blaginin (via GitHub)" <gi...@apache.org> on 2025/02/15 21:25:28 UTC
[PR] Set projection before configuring the source [datafusion]
blaginin opened a new pull request, #14685:
URL: https://github.com/apache/datafusion/pull/14685
## Which issue does this PR close?
Closes https://github.com/apache/datafusion/issues/14679
## Rationale for this change
`FileScanConfig::new` now also configures source, but this currently without projection set before. And so when `source.with_statistics` is called, it is passed with yet empty `projected_statistics`
## What changes are included in this PR?
Setting projection before configuring the source... but should the old method exist?
## Are these changes tested?
todo
## Are there any user-facing changes?
Potentially, yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #14685:
URL: https://github.com/apache/datafusion/pull/14685
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "milenkovicm (via GitHub)" <gi...@apache.org>.
milenkovicm commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2679834606
Would it make sense to add a test which would cover plan round trip?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1975339518
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -345,6 +345,32 @@ impl FileScanConfig {
/// Set the projection of the files
pub fn with_projection(mut self, projection: Option<Vec<usize>>) -> Self {
self.projection = projection;
+ self.with_updated_statistics()
+ }
+
+ // Update source statistics with the current projection data
+ fn with_updated_statistics(mut self) -> Self {
+ let max_projection_column = *self
+ .projection
+ .as_ref()
+ .and_then(|proj| proj.iter().max())
+ .unwrap_or(&0);
+
+ if max_projection_column
+ >= self.file_schema.fields().len() + self.table_partition_cols.len()
+ {
Review Comment:
removed this now. but answering to the question - this could happen if `projection` set but `table_partition_cols` isn't yet set (or vice versa).
This whole logic should be much cleaner when we switch to the builder approach (I want to do a PR on top after this one is merged)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2690935156
Thanks again for sticking with this @blaginin -- the result looks really nice
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1974936267
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -345,6 +345,32 @@ impl FileScanConfig {
/// Set the projection of the files
pub fn with_projection(mut self, projection: Option<Vec<usize>>) -> Self {
self.projection = projection;
+ self.with_updated_statistics()
+ }
+
+ // Update source statistics with the current projection data
+ fn with_updated_statistics(mut self) -> Self {
+ let max_projection_column = *self
+ .projection
+ .as_ref()
+ .and_then(|proj| proj.iter().max())
+ .unwrap_or(&0);
+
+ if max_projection_column
+ >= self.file_schema.fields().len() + self.table_partition_cols.len()
+ {
+ // we don't yet have enough information (file schema info or partition column info) to perform projection
+ return self;
+ }
+
+ let (
+ _projected_schema,
+ _constraints,
+ projected_statistics,
+ _projected_output_ordering,
+ ) = self.project();
+
+ self.source = self.source.with_statistics(projected_statistics);
Review Comment:
That's a great idea! We can't use `self.source.statistics` directly, because statistics match projection we're applying - so I had to apply projection before (https://github.com/apache/datafusion/pull/14685/commits/89ed225dcbe97ce9e9d1245d12e05637e3637f35)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1969963785
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -345,6 +345,32 @@ impl FileScanConfig {
/// Set the projection of the files
pub fn with_projection(mut self, projection: Option<Vec<usize>>) -> Self {
self.projection = projection;
+ self.with_updated_statistics()
+ }
+
+ // Update source statistics with the current projection data
+ fn with_updated_statistics(mut self) -> Self {
+ let max_projection_column = *self
+ .projection
+ .as_ref()
+ .and_then(|proj| proj.iter().max())
+ .unwrap_or(&0);
+
+ if max_projection_column
+ >= self.file_schema.fields().len() + self.table_partition_cols.len()
+ {
+ // we don't yet have enough information (file schema info or partition column info) to perform projection
+ return self;
+ }
+
+ let (
+ _projected_schema,
+ _constraints,
+ projected_statistics,
+ _projected_output_ordering,
+ ) = self.project();
+
+ self.source = self.source.with_statistics(projected_statistics);
self
Review Comment:
How about
```rust
let source = self.source.clone();
self.with_source(source)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1974936267
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -345,6 +345,32 @@ impl FileScanConfig {
/// Set the projection of the files
pub fn with_projection(mut self, projection: Option<Vec<usize>>) -> Self {
self.projection = projection;
+ self.with_updated_statistics()
+ }
+
+ // Update source statistics with the current projection data
+ fn with_updated_statistics(mut self) -> Self {
+ let max_projection_column = *self
+ .projection
+ .as_ref()
+ .and_then(|proj| proj.iter().max())
+ .unwrap_or(&0);
+
+ if max_projection_column
+ >= self.file_schema.fields().len() + self.table_partition_cols.len()
+ {
+ // we don't yet have enough information (file schema info or partition column info) to perform projection
+ return self;
+ }
+
+ let (
+ _projected_schema,
+ _constraints,
+ projected_statistics,
+ _projected_output_ordering,
+ ) = self.project();
+
+ self.source = self.source.with_statistics(projected_statistics);
Review Comment:
That's a great idea! We can't use `self.source.statistics` directly, because statistics match projection we're applying - so I had to apply projection before (https://github.com/apache/datafusion/pull/14685/commits/89ed225dcbe97ce9e9d1245d12e05637e3637f35).
This made the PR a bit messier, and I had to comment several test lines - LMK if you prefer the old version
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2689497827
Hi @blaginin -- I also wrote some additional tests in a different PR:
- https://github.com/apache/datafusion/issues/14679
Feel free to bring them into this PR (or we can keep them in a separate PR too)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "mertak-synnada (via GitHub)" <gi...@apache.org>.
mertak-synnada commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2667684649
Yes, I agree with the builder approach, it might be helpful for such cases. However, I'm a bit concerned about with the explicit approach, since it might be forgotten. It looks like this should be in the FileScanConfigs responsibility, that's why I think we should call the source updater method implicitly on both with_projection and with_table_partition_cols
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "berkaysynnada (via GitHub)" <gi...@apache.org>.
berkaysynnada commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1971022680
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -345,6 +345,32 @@ impl FileScanConfig {
/// Set the projection of the files
pub fn with_projection(mut self, projection: Option<Vec<usize>>) -> Self {
self.projection = projection;
+ self.with_updated_statistics()
+ }
+
+ // Update source statistics with the current projection data
+ fn with_updated_statistics(mut self) -> Self {
+ let max_projection_column = *self
+ .projection
+ .as_ref()
+ .and_then(|proj| proj.iter().max())
+ .unwrap_or(&0);
+
+ if max_projection_column
+ >= self.file_schema.fields().len() + self.table_partition_cols.len()
+ {
Review Comment:
How is this case possible? it seems not obvious to me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1974977572
##########
datafusion/core/src/datasource/file_format/parquet.rs:
##########
@@ -1934,7 +1934,8 @@ mod tests {
// test metadata
assert_eq!(exec.statistics()?.num_rows, Precision::Exact(8));
- assert_eq!(exec.statistics()?.total_byte_size, Precision::Exact(671));
+ // assert_eq!(exec.statistics()?.total_byte_size, Precision::Exact(671));
+ // todo: uncomment when FileScanConfig::projection_stats puts byte size
Review Comment:
I don't think those lines were correct, because tests had the same bug: projection was set _after_ the source, and so source statistics (which were used here) weren't really updated properly
<img width="629" alt="RustRover-EAP 2025-02-28 08 01 28" src="https://github.com/user-attachments/assets/9ed99086-e605-4365-a2ee-fff4a66f4bae" />
A proper way to fix this is set bytes size in `projection_stats`
<img width="469" alt="image" src="https://github.com/user-attachments/assets/c37adb95-2562-4283-b74f-de0d1fdb37bb" />
Since it's a separate existing todo, I think it's better to change it in a PR on top of this one
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2688185398
Thank you Andrew!! I'll resolve all the comments later today
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1975526113
##########
datafusion/datasource/src/file_scan_config.rs:
##########
@@ -433,54 +494,13 @@ impl FileScanConfig {
);
}
- let proj_indices = if let Some(proj) = &self.projection {
- proj
- } else {
- let len = self.file_schema.fields().len() + self.table_partition_cols.len();
- &(0..len).collect::<Vec<_>>()
- };
-
- let mut table_fields = vec![];
- let mut table_cols_stats = vec![];
- for idx in proj_indices {
- if *idx < self.file_schema.fields().len() {
- let field = self.file_schema.field(*idx);
- table_fields.push(field.clone());
- table_cols_stats.push(self.statistics.column_statistics[*idx].clone())
- } else {
- let partition_idx = idx - self.file_schema.fields().len();
- table_fields.push(self.table_partition_cols[partition_idx].to_owned());
- // TODO provide accurate stat for partition column (#1186)
- table_cols_stats.push(ColumnStatistics::new_unknown())
- }
- }
-
- let table_stats = Statistics {
- num_rows: self.statistics.num_rows,
- // TODO correct byte size?
- total_byte_size: Precision::Absent,
- column_statistics: table_cols_stats,
- };
-
- let projected_schema = Arc::new(Schema::new_with_metadata(
- table_fields,
- self.file_schema.metadata().clone(),
- ));
-
- let projected_constraints = self
- .constraints
- .project(proj_indices)
- .unwrap_or_else(Constraints::empty);
+ let schema = self.projected_schema();
Review Comment:
this looks really nice now
##########
datafusion/proto/tests/cases/roundtrip_physical_plan.rs:
##########
@@ -1626,7 +1659,6 @@ async fn roundtrip_parquet_select_star_predicate() -> Result<()> {
roundtrip_test_sql_with_context(sql, &ctx).await
}
-#[ignore = "Test failing due to https://github.com/apache/datafusion/issues/14679"]
Review Comment:
🎉
##########
datafusion/core/src/datasource/file_format/parquet.rs:
##########
@@ -1934,7 +1934,8 @@ mod tests {
// test metadata
assert_eq!(exec.statistics()?.num_rows, Precision::Exact(8));
- assert_eq!(exec.statistics()?.total_byte_size, Precision::Exact(671));
+ // assert_eq!(exec.statistics()?.total_byte_size, Precision::Exact(671));
+ // todo: uncomment when FileScanConfig::projection_stats puts byte size
Review Comment:
I filed this ticket to track:
- https://github.com/apache/datafusion/issues/14936
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2690999140
Thank you for the help! 🥹 I'll do follow up prs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2684756793
I am pretty sure I am hitting this issue while upgrading to delta.rs as well in
- https://github.com/delta-io/delta-rs/pull/3261
I will help shortly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2688468421
> Thank you Andrew!! I'll resolve all the comments later today
Thank you for working on this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "berkaysynnada (via GitHub)" <gi...@apache.org>.
berkaysynnada commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1971022680
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -345,6 +345,32 @@ impl FileScanConfig {
/// Set the projection of the files
pub fn with_projection(mut self, projection: Option<Vec<usize>>) -> Self {
self.projection = projection;
+ self.with_updated_statistics()
+ }
+
+ // Update source statistics with the current projection data
+ fn with_updated_statistics(mut self) -> Self {
+ let max_projection_column = *self
+ .projection
+ .as_ref()
+ .and_then(|proj| proj.iter().max())
+ .unwrap_or(&0);
+
+ if max_projection_column
+ >= self.file_schema.fields().len() + self.table_partition_cols.len()
+ {
Review Comment:
How is this case possible?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2687847176
I filed a separate ticket for the issue I was seeing in the delta-rs upgrade
- https://github.com/apache/datafusion/issues/14905
I tried running the delta-rs upgrade with this change and it also fixes the delta.rs issue 🤗
I will spend more time today looking at this code / trying to help
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2690910151
It would be nice if we could avoid having Statistics on both FileScanConfig and file_source. I played around with this but hit some issues and don't have time to pursue it now. Filed this ticket to track:
- https://github.com/apache/datafusion/issues/14937
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2691011853
> Thank you for the help! 🥹 I'll do follow up prs
Thank you so much@
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2664009187
Thanks for checking! I also thought that, but couldn't do because `project` relies on other fields to be set. You can see that for example in `partition_column_projector` test, where we call `with_projection` before `with_table_partition_cols`, so recomputing on isn't feasible
I just pushed explicit refresh, but maybe it's time to introduce `FileScanConfigBuilder` (in a separate pr)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "mertak-synnada (via GitHub)" <gi...@apache.org>.
mertak-synnada commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2662675526
Hello, thanks for reproducing the bug and the PR!
I think the problem is not with the call order of the functions but with missing behavior. How about changing the `with_projection` method to update statistics as well? Just like we do in the `with_source`.
```rust
let (
_projected_schema,
_constraints,
projected_statistics,
_projected_output_ordering,
) = self.project();
self.source = source.with_statistics(projected_statistics);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#discussion_r1971726551
##########
datafusion/core/src/datasource/physical_plan/file_scan_config.rs:
##########
@@ -345,6 +345,32 @@ impl FileScanConfig {
/// Set the projection of the files
pub fn with_projection(mut self, projection: Option<Vec<usize>>) -> Self {
self.projection = projection;
+ self.with_updated_statistics()
+ }
+
+ // Update source statistics with the current projection data
+ fn with_updated_statistics(mut self) -> Self {
+ let max_projection_column = *self
+ .projection
+ .as_ref()
+ .and_then(|proj| proj.iter().max())
+ .unwrap_or(&0);
+
+ if max_projection_column
+ >= self.file_schema.fields().len() + self.table_partition_cols.len()
+ {
+ // we don't yet have enough information (file schema info or partition column info) to perform projection
+ return self;
+ }
+
+ let (
+ _projected_schema,
+ _constraints,
+ projected_statistics,
+ _projected_output_ordering,
+ ) = self.project();
+
+ self.source = self.source.with_statistics(projected_statistics);
Review Comment:
I don't fully understand why the source would need projected statistics
I am testing out if the issue is that the FileScanConfig is providing the wrong statistics (like maybe this line should be self.statistics rather than self.source.statistics
https://github.com/apache/datafusion/blob/1c54b38e4a4012fd8d1b4f48e2c3d6d35016bad0/datafusion/core/src/datasource/physical_plan/file_scan_config.rs#L233-L232
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Set projection before configuring the source [datafusion]
Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on PR #14685:
URL: https://github.com/apache/datafusion/pull/14685#issuecomment-2669773527
Fair, let's do it that way as a hotfix and properly solve with the builder then 🤝
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org