This repository has been archived by the owner on May 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Groupby and Aggregates - Instructions and Codegen overhaul #26
Open
Samyak2
wants to merge
26
commits into
main
Choose a base branch
from
groupby
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
Are there test cases illustrating what code will be generated given the sample SQL we use in the blog post? |
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
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.
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, col3
This 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 }
Interesting, is there an example for the following too? select
col1,
col3 + 1,
max(col2 + 1)
from abc
group by col1, col3 |
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
GroupBy
instruction and found it very lacking (see #16). This PR represents an overhaul of it.Partially fixes #24
Changes
Aggregate
instruction to calculate aggregations on a grouped tableCodegenContext
struct to make passing them around easier.GroupBy
will now produce a grouped table which will be lazily evaluated. Note: the evaluation is not in scope for this PR.Some questions/concerns