Repository navigation
feat: incremental resolve, IR & type checking - #593
Conversation
|
TODO:
|
|
This comment will be me thinking out loud on how to internally structure the compiler. In my previous big commits, I've added Because SQL has interesting rules on which variables can contain aliases and which not (i.e. WHERE cannot and ORDER BY must), each variable has to be able to be materialized both as an alias or as an expression, depending on the materialization location. This is why the name resolver (first stage of semantic analysis) moves all expressions from AST to Now, I've split the resolver into 3 stages: name resolver, type checker and transform constructor.
One approach that would solve 4. would be to keep all expressions in AST and resolve them as soon as possible - maybe during type checking. This would also simplify some parts of the code base, because there would be no need to traverse both AST and declarations anymore. All that said, I'll go and sleep on it before going down into another major refactor. |
|
@max-sixty, is this a valid query? derive a = 5If we want to keep promises of transforms I'd say it is not, because But in such case we should provide a syntax of table literals: #286 |
I could see two options:
I do think |
|
My concern is that derive only adds columns not rows. from null # empty table, 0 column, 0 rows?
derive a = 5 # 1 column, 0 rows?If derive has special behavior without last parameter, we need default values for positional arguments (which breaks other things). So I'd stick with option 2. |
Yes good point. Agree with option 2! Meta point — I think it's good that we're starting to hit these issues and it's good that we're resolving them in a conceptually correct way, even if that has small backward incompatible changes, or deviations from SQL. It's forcing us to confront the SQL warts we didn't even know about! |
|
I agree very much on that - one should be able to scan over half of the transforms then be able to read PRQL and expect what is a result of a query. |
83ec087 to
e6fc0bd
Compare
7f28d36 to
3d85402
Compare
3d85402 to
3f6025b
Compare
|
70 tests pass, 17 fail. @max-sixty now, the semantic branch should be quite stable in the sense most of my major changes have been applied. I still have plans to change-up materializer (which will also be renamed into anchorer or something). I also have plans for IR to ditch Declarations, so after that I hope it will be easier to debug. And I also disabled duckdb integration tests - I got tired of waiting for duckdb to compile. So maybe rather base from commit |
Awesome, I will switch over to it.
In my core iteration loop (at the bottom of https://github.com/prql/prql/blob/main/CONTRIBUTING.md), I include |
|
I was doing that a lot, but So I just keep rebasing the last commit to the top of my chain so I can remove it before the merge. That's why I gave you the notice, so you will not include it in your commit chain. |
FYI you're correct that it does compile all dev-dependencies when running tests. But on my system I can't seem to make it recompile once it's been compiled once. If you can reproduce, I'm very happy to either fix it or move the integration tests back into a separate crate. |
|
As discussed, this branch (and this PR) will now turn into a feature branch that we merge into. The plan is to finish the work that I started and to onboard @max-sixty, @priithaamer and anyone who also wants to learn our codebase. I promise not to rebase this branch anymore. We will also refrain from merging changes from the main branch, so it will be easier to rebase/squash back to the main branch at the end. Currently, there are many tests are failing: some produce errors/panics and some don't match the snapshots. Make sure not to accept any failing insta snapshots, because they (mostly) fail for a reason and we need to fix the compiler not the test. So we will be merging commits that don't pass CI tests, but please run There are some code blocks commented out, mostly dealing with windowing. Don't delete them, we will still need that code. To get started, I suggest reading ARCHITECTURE.md (on this branch, I updated it a little) and the two book pages I wrote on the A few quick hints:
I'll be adding |
|
@aljazerzen how do you want to handle merging Doing #1048 would be useful for this, so "all existing tests pass" can be a marker for the merge being successful. |
* feat: Add clickhouse dialect
fix: lowering windows
TODO: