Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
A very-WIP implementation of the PRQL plugin, for discussion #5982
base: main
Are you sure you want to change the base?
A very-WIP implementation of the PRQL plugin, for discussion #5982
Changes from all commits
506f2c9
fa3f172
5a8fd1e
ebff2ce
c9572c3
8eece38
86eb68f
bc8b650
dddb0bf
4729404
90223ed
e0c32f4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
It sounds like this piece is the biggest current challenge, and the thing that would require the most refactoring to make pluggable.
Currently,
SimpleSQLParser
is used in all of these places:ModelParser
(even for Python models)AnalysisParser
SingularTestParser
SqlBlockParser
(for semantic layer queries)SeedParser
(!), even thoughrender_with_context
is a total no-opWe shouldn't be looking to create new node types for each language — these should still be models, analyses, tests, etc — but it's clear that we need some way to allow a language plugin to define its own parser, and then provide it to resources matching that language input.
It also looks like the real Jinja-SQL entrypoint is
ConfiguredParser.render_with_context
. We'd probably want to split that out, to live on a dedicatedJinjaSQLParser
instead!Caveats:
update_parsed_node_config_dict
andupdate_parsed_node_name
, to respect rules around hooks and database/schema/alias — those have more to do with model configuration than model language, and the fact that we've stretched Jinja into a "rules engine" for configuration that goes beyond its more-straightforwardly understood role as a SQL template.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.
After taking another look here — with plans to do some hacking on/around this soon! — I think we'd want the actual
.compile()
call (PRQL → SQL transpilation) to happen within compilation, rather than during parsing. Here's where we do that for Python.I think the goal here, within the parser, should just be to provide the set of
references
, and then pick up again at compile time. Something to also think about: Certain modeling languages will want a database connection at compile time (e.g. Jinja-SQL, Cody's prototype work on Ibis); some won't need one (e.g. Snowpark/PySpark Python, PRQL), and so shouldn't require one.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.
OK great, that seems very reasonable.
Would you have it as an
if
inCompiler
like the current python implementation, or inherit a class for each lang; i.e.CompilerPython
/CompilerPrql
?