Skip to content

Conversation

@goldmedal
Copy link
Contributor

@goldmedal goldmedal commented Aug 25, 2024

Which issue does this PR close?

Closes #12154.

Rationale for this change

Besides projections, I also handle the filters and fetch for TableScan.

What changes are included in this PR?

Are these changes tested?

yes

Are there any user-facing changes?

no

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions labels Aug 25, 2024
Comment on lines 532 to 537
// 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"
);
}
Copy link
Contributor Author

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.

Copy link
Contributor

@devinjdangelo devinjdangelo left a 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.

@goldmedal
Copy link
Contributor Author

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.

Copy link
Contributor

@alamb alamb left a 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
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed #12368

Copy link
Contributor

@phillipleblanc phillipleblanc left a 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!

) -> Result<LogicalPlan> {
match plan {
LogicalPlan::TableScan(table_scan) => {
// TODO: support filters for table scan with alias.Remove this check after #12368 issue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

@alamb
Copy link
Contributor

alamb commented Sep 7, 2024

🚀 thanks @goldmedal for the code and @devinjdangelo and @phillipleblanc for the review

@alamb alamb merged commit ddbdf4b into apache:main Sep 7, 2024
@goldmedal
Copy link
Contributor Author

Thanks @devinjdangelo @alamb @phillipleblanc for the review.

@goldmedal goldmedal deleted the feature/12154-unparse-table-pushdown branch September 13, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unparse TableScan with pushdown projection

4 participants