-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Unparse TableScan with projections, filters or fetch to SQL string #12158
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
Unparse TableScan with projections, filters or fetch to SQL string #12158
Conversation
datafusion/sql/src/unparser/plan.rs
Outdated
| // TODO: support filters for table scan with alias | ||
| if alias.is_some() && !table_scan.filters().is_empty() { | ||
| return not_impl_err!( | ||
| "Subquery alias is not supported for table scan with pushdown filters" | ||
| ); | ||
| } |
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.
There are some issues with handling the table name prefix for the column. It isn't simple. I think we can create another issue for it. See the example in the unit tests.
devinjdangelo
left a comment
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.
Thanks @goldmedal! This looks reasonable to me. The only possible controversial change I notice is the added public methods in the expr crate. They seem reasonable enough to me though.
Thanks, @devinjdangelo. I removed the controversial parts to align with the coding style. I think they might not be necessary for this PR's purpose. |
alamb
left a comment
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.
Thanks @goldmedal and @devinjdangelo
I took a look at this PR and it looks good from my point of view. The PR has a conflict that needs to be resolved prior to merging.
cc @phillipleblanc as I think you have been reviewing code in this area as well
| .map(Self::new) | ||
| } | ||
|
|
||
| /// Convert a table provider into a builder with a TableScan with filter and fetch |
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 seems like a reasonably helpful API in my opinion
| "SELECT * FROM t1 WHERE ((t1.id > 1) AND (t1.age < 2))" | ||
| ); | ||
|
|
||
| // TODO: support filters for table scan with alias |
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.
I suggest we file a ticket for this gap and leave a link to it in this comment
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.
filed #12368
phillipleblanc
left a comment
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 PR makes sense to me. Thanks!
datafusion/sql/src/unparser/plan.rs
Outdated
| ) -> Result<LogicalPlan> { | ||
| match plan { | ||
| LogicalPlan::TableScan(table_scan) => { | ||
| // TODO: support filters for table scan with alias.Remove this check after #12368 issue. |
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.
| // TODO: support filters for table scan with alias.Remove this check after #12368 issue. | |
| // TODO: support filters for table scan with alias. Remove this check after #12368 issue. |
|
🚀 thanks @goldmedal for the code and @devinjdangelo and @phillipleblanc for the review |
|
Thanks @devinjdangelo @alamb @phillipleblanc for the review. |
Which issue does this PR close?
Closes #12154.
Rationale for this change
Besides
projections, I also handle thefiltersandfetchfor TableScan.What changes are included in this PR?
Are these changes tested?
yes
Are there any user-facing changes?
no