Skip to content
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

Saving parsed query to the context #2684

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wk8
Copy link

@wk8 wk8 commented Oct 5, 2024

Sometimes it's nice to be able to access the parsed query, say in a Table's callbacks; for example, if one implements a table backed by a system that allows fast access for very specific queries, it might not be possible (or at least not easy) to take advantage of that using one of the pre-defined *Table interfaces. In that case, the most straightforward way to implement this would be to return the relevant subset of rows from PartitionRows, depending on the query.

This patch allows to access the already parsed query, instead of parsing it all over again.

Happy to add tests if you're okay with the general idea.

Sometimes it's nice to be able to access the parsed query, say in a `Table`'s callbacks; for example, if one implements a table backed by a system that allows fast access for very specific queries, it might not be possible (or at least not easy) to take advantage of that using one of the pre-defined `*Table` interfaces. In that case, the most straightforward way to implement this would be to return the relevant subset of rows from `PartitionRows`, depending on the query.

This patch allows to access the already parsed query, instead of parsing it all over again.
@max-hoffman
Copy link
Contributor

This is pretty safe to merge, I do think the way you plan to use the AST might give you some issues. Normally we would fold execution time decision making into the plan layer with transformation rules. Depending on how you are using GMS, if might be possible to extend the engine's analyzer with custom rules. That would look similar to your AST walk, but on a plan sql.Node instead (we have a lot of search and pattern matching helper functions). Setting a property on your custom table at planning time generally lends itself to easier extensibility, testing, debugging, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants