You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Resolve partiton, window and sort of ast::TransformCall #1044
@aljazerzen can you confirm my understanding is correct?
Take the first case:
from employees
sort salary
derive salary_rank = rank # sort should be set to vec![(salary,ASC)]
This has a debug output from pbpaste | cargo run -p prql-compiler -- debug of:
- Pipeline:
TransformCall:
kind: !Deriveassigns:
- Ident: salary_ranktbl:
TransformCall:
kind: !Sort # Is this not the right place for the sort described above?by:
- direction: Asccolumn:
Ident: salarytbl:
TransformCall:
kind: !FromIdent: employeespartition: []window:
kind: Rowsrange:
start: nullend: nullsort: [] # Should it be here? Is that what you mean by "we have figured out that this function call works on a table."?partition: []window:
kind: Rowsrange:
start: nullend: nullsort: [] # Or here?partition: []window:
kind: Rowsrange:
start: nullend: nullsort: [] # Or even here?? :)
...none of them are on window, where I presume they'll end up in SQL, but I'm guessing that comes later in the translation process.
The sort should be set on at your third and fourth comment, because these two sort attributes belong to sort and derive, respectively.
We need this sort attribute set for all transforms, because some of them will need it afterwards (for example derive if contains window functions and take X, which may be converted derive row_number = rank | filter row_number < X).
I few things: I underestimated difficulty of this task. When I wanted to explain it better, I realized that it's too hard and when I tried to get started on it I found some undocumented bits that would block anyone who hasn't written that code.
A few things:
I've cleaned-up serialization of TransformCall, so default values don't get serialized.
This task should also handle flattening of group/window transforms.
Having more than one transfrom in inner pipeline of group/window does not work currently, but is out of scope of this task.
I've written the framework of how it should work on branch semantic-flattener. Group works, it assigns partition to all inner transforms (or rather the only inner transfrom, because of the bug mentioned).
Sort is prepared to be done, comments on Flattener give more info on that.
Window is not done yet, but should be similar to group.
Test case: sort
from employees
sort salary
derive salary_rank = rank
Thanks for completing this @aljazerzen — sorry this was another one you ended up doing yourself. I'm reading through your code now so at least I'm keeping pace.
Activity
max-sixty commentedon Oct 23, 2022
I'll take this
max-sixty commentedon Oct 23, 2022
@aljazerzen can you confirm my understanding is correct?
Take the first case:
This has a debug output from
pbpaste | cargo run -p prql-compiler -- debugof:...none of them are on
window, where I presume they'll end up in SQL, but I'm guessing that comes later in the translation process.aljazerzen commentedon Oct 24, 2022
The sort should be set on at your third and fourth comment, because these two sort attributes belong to sort and derive, respectively.
We need this sort attribute set for all transforms, because some of them will need it afterwards (for example derive if contains window functions and take X, which may be converted
derive row_number = rank | filter row_number < X).Did I understand your question correctly?
max-sixty commentedon Oct 24, 2022
OK great. Does this mean the diff should be:
Do we also replace the
Sorttransform with theFrom, like:Thanks!
aljazerzen commentedon Oct 25, 2022
Yeah that's it exactly.
We don't need to remove
Sort, it will still be needed to for constructing ORDER BY. It's just that it has additional effects on some transforms.aljazerzen commentedon Oct 26, 2022
I few things: I underestimated difficulty of this task. When I wanted to explain it better, I realized that it's too hard and when I tried to get started on it I found some undocumented bits that would block anyone who hasn't written that code.
A few things:
I've written the framework of how it should work on branch
semantic-flattener. Group works, it assignspartitionto all inner transforms (or rather the only inner transfrom, because of the bug mentioned).Sort is prepared to be done, comments on Flattener give more info on that.
Window is not done yet, but should be similar to group.
Test case: sort
cargo run debughas been changed as:- Pipeline: TransformCall: kind: !Derive assigns: - SString: - !String RANK() tbl: TransformCall: kind: !Sort by: - direction: Asc column: Ident: namespace: null name: salary tbl: TransformCall: kind: !From Ident: namespace: null name: employees + sort: + - direction: Asc + column: + Ident: + namespace: null + name: salary + sort: + - direction: Asc + column: + Ident: + namespace: null + name: salaryTest case: group
So for:
...
cargo run debughas been changed from ...... to ...
Test case: window
Derive should have
windowset.max-sixty commentedon Nov 9, 2022
Thanks for completing this @aljazerzen — sorry this was another one you ended up doing yourself. I'm reading through your code now so at least I'm keeping pace.
aljazerzen commentedon Nov 10, 2022
Don't feel bad, because as I said, this turned out to be more complex than I expected.