This repository was archived by the owner on May 12, 2024. It is now read-only.
Conversation
Member
|
Are there test cases illustrating what code will be generated given the sample SQL we use in the blog post? |
Collaborator
Author
|
Not yet. I'm working on it currently. |
Not yet done for Function
commented out the original version for reference
but are they correct?
Samyak2
commented
May 8, 2023
Collaborator
Author
Samyak2
left a comment
There was a problem hiding this comment.
This is now complete. Took a lot longer than expected :(
For this query:
select
col1,
col3 + 1,
max(col2) + 1,
count(1) as count
from abc
group by col1, col3This is the generated code:
Source { index: %0, name: abc }
Empty { index: %1 }
Project { input: %0, output: %1, expr: column 'col2', alias: __otter_temp_col_1 }
Project { input: %0, output: %1, expr: 1, alias: __otter_temp_col_3 }
Empty { index: %2 }
GroupBy { input: %1, output: %2, expr: column 'col1' }
Empty { index: %3 }
GroupBy { input: %2, output: %3, expr: column 'col3' }
Empty { index: %4 }
Aggregate { input: %3, output: %4, func: Agg(max), col_name: __otter_temp_col_1, alias: __otter_temp_col_2 }
Aggregate { input: %3, output: %4, func: Agg(count), col_name: __otter_temp_col_3, alias: __otter_temp_col_4 }
Empty { index: %5 }
Project { input: %0, output: %5, expr: column 'col1', alias: None }
Project { input: %0, output: %5, expr: (column 'col3' + 1), alias: None }
Project { input: %4, output: %5, expr: (column '__otter_temp_col_2' + 1), alias: None }
Project { input: %4, output: %5, expr: column '__otter_temp_col_4', alias: count }
Return { index: %5 }
Member
|
Interesting, is there an example for the following too? select
col1,
col3 + 1,
max(col2 + 1)
from abc
group by col1, col3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
We took a second look at the
GroupByinstruction and found it very lacking (see #16). This PR represents an overhaul of it.Partially fixes #24
Changes
Aggregateinstruction to calculate aggregations on a grouped tableCodegenContextstruct to make passing them around easier.GroupBywill now produce a grouped table which will be lazily evaluated. Note: the evaluation is not in scope for this PR.Some questions/concerns