You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "jayzhan211 (via GitHub)" <gi...@apache.org> on 2025/04/23 11:38:13 UTC
[PR] Project inline [datafusion]
jayzhan211 opened a new pull request, #15825:
URL: https://github.com/apache/datafusion/pull/15825
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
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] Preserve projection for inline scan [datafusion]
Posted by "vadimpiven (via GitHub)" <gi...@apache.org>.
vadimpiven commented on code in PR #15825:
URL: https://github.com/apache/datafusion/pull/15825#discussion_r2057920398
##########
datafusion/core/tests/execution/logical_plan.rs:
##########
@@ -96,3 +100,37 @@ where
};
element
}
+
+#[test]
+fn inline_scan_projection_test() -> Result<()> {
+ let name = UNNAMED_TABLE;
+ let column = "a";
+
+ let schema = Schema::new(vec![
+ Field::new("a", DataType::Int32, false),
+ Field::new("b", DataType::Int32, false),
+ ]);
+ let projection = vec![schema.index_of(column)?];
+
+ let provider = ViewTable::new(
+ LogicalPlan::EmptyRelation(EmptyRelation {
+ produce_one_row: false,
+ schema: DFSchemaRef::new(DFSchema::try_from(schema)?),
+ }),
+ None,
+ );
+ let source = provider_as_source(Arc::new(provider));
+
+ let plan = LogicalPlanBuilder::scan(name, source, Some(projection))?.build()?;
+
+ assert_snapshot!(
+ format!("{plan}"),
+ @r"
Review Comment:
Actually, I just thought that the correct test would be
```
assert_eq!(
plan.schema().field_names(),
vec![format!("{name}.{column}")]
);
```
because what matters is that projection is applied, not how
--
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] Preserve projection for inline scan [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #15825:
URL: https://github.com/apache/datafusion/pull/15825#issuecomment-2825860245
You can merge this PR, I had kept the commit from @vadimpiven
--
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] Preserve projection for inline scan [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #15825:
URL: https://github.com/apache/datafusion/pull/15825#discussion_r2064516964
##########
datafusion/expr/src/logical_plan/builder.rs:
##########
@@ -501,6 +501,21 @@ impl LogicalPlanBuilder {
if table_scan.filters.is_empty() {
if let Some(p) = table_scan.source.get_logical_plan() {
let sub_plan = p.into_owned();
+
+ if let Some(proj) = table_scan.projection {
Review Comment:
👍
--
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] Preserve projection for inline scan [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 merged PR #15825:
URL: https://github.com/apache/datafusion/pull/15825
--
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] Preserve projection for inline scan [datafusion]
Posted by "vadimpiven (via GitHub)" <gi...@apache.org>.
vadimpiven commented on code in PR #15825:
URL: https://github.com/apache/datafusion/pull/15825#discussion_r2057920398
##########
datafusion/core/tests/execution/logical_plan.rs:
##########
@@ -96,3 +100,37 @@ where
};
element
}
+
+#[test]
+fn inline_scan_projection_test() -> Result<()> {
+ let name = UNNAMED_TABLE;
+ let column = "a";
+
+ let schema = Schema::new(vec![
+ Field::new("a", DataType::Int32, false),
+ Field::new("b", DataType::Int32, false),
+ ]);
+ let projection = vec![schema.index_of(column)?];
+
+ let provider = ViewTable::new(
+ LogicalPlan::EmptyRelation(EmptyRelation {
+ produce_one_row: false,
+ schema: DFSchemaRef::new(DFSchema::try_from(schema)?),
+ }),
+ None,
+ );
+ let source = provider_as_source(Arc::new(provider));
+
+ let plan = LogicalPlanBuilder::scan(name, source, Some(projection))?.build()?;
+
+ assert_snapshot!(
+ format!("{plan}"),
+ @r"
Review Comment:
Actually, I just thought that the correct test would be
```
assert_eq!(
plan.schema().field_names(),
vec![format!("{name}.{column}")]
);
```
because what matters is that projection is applied, not how. Updated the code in my 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] Preserve projection for inline scan [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #15825:
URL: https://github.com/apache/datafusion/pull/15825#discussion_r2057104794
##########
datafusion/core/tests/execution/logical_plan.rs:
##########
@@ -96,3 +100,37 @@ where
};
element
}
+
+#[test]
+fn inline_scan_projection_test() -> Result<()> {
+ let name = UNNAMED_TABLE;
+ let column = "a";
+
+ let schema = Schema::new(vec![
+ Field::new("a", DataType::Int32, false),
+ Field::new("b", DataType::Int32, false),
+ ]);
+ let projection = vec![schema.index_of(column)?];
+
+ let provider = ViewTable::new(
+ LogicalPlan::EmptyRelation(EmptyRelation {
+ produce_one_row: false,
+ schema: DFSchemaRef::new(DFSchema::try_from(schema)?),
+ }),
+ None,
+ );
+ let source = provider_as_source(Arc::new(provider));
+
+ let plan = LogicalPlanBuilder::scan(name, source, Some(projection))?.build()?;
+
+ assert_snapshot!(
+ format!("{plan}"),
+ @r"
Review Comment:
you mean to move out the string to `expected`?
but for insta test, we keep the string inline to update easily
--
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] Preserve projection for inline scan [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #15825:
URL: https://github.com/apache/datafusion/pull/15825#issuecomment-2827031377
Thanks @xudong963 @vadimpiven
--
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] Preserve projection for inline scan [datafusion]
Posted by "vadimpiven (via GitHub)" <gi...@apache.org>.
vadimpiven commented on code in PR #15825:
URL: https://github.com/apache/datafusion/pull/15825#discussion_r2056286726
##########
datafusion/core/tests/execution/logical_plan.rs:
##########
@@ -96,3 +100,37 @@ where
};
element
}
+
+#[test]
+fn inline_scan_projection_test() -> Result<()> {
+ let name = UNNAMED_TABLE;
+ let column = "a";
+
+ let schema = Schema::new(vec![
+ Field::new("a", DataType::Int32, false),
+ Field::new("b", DataType::Int32, false),
+ ]);
+ let projection = vec![schema.index_of(column)?];
+
+ let provider = ViewTable::new(
+ LogicalPlan::EmptyRelation(EmptyRelation {
+ produce_one_row: false,
+ schema: DFSchemaRef::new(DFSchema::try_from(schema)?),
+ }),
+ None,
+ );
+ let source = provider_as_source(Arc::new(provider));
+
+ let plan = LogicalPlanBuilder::scan(name, source, Some(projection))?.build()?;
+
+ assert_snapshot!(
+ format!("{plan}"),
+ @r"
Review Comment:
May be it would be more readable to format like here https://github.com/apache/datafusion/blob/03fa3b99f6c87b04321f85ecdc71b4b54ed4d884/datafusion/optimizer/src/eliminate_filter.rs#L142-L145 ?
--
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