-
Notifications
You must be signed in to change notification settings - Fork 279
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
For avg functions replacing it with (sum / count), count(*) #399
Merged
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
@mergify rebase |
yuzhichang
force-pushed
the
agg_stream
branch
from
December 30, 2023 14:46
5a54225
to
aa14de8
Compare
✅ Branch has been successfully rebased |
JinHai-CN
reviewed
Jan 2, 2024
JinHai-CN
reviewed
Jan 2, 2024
JinHai-CN
reviewed
Jan 2, 2024
JinHai-CN
reviewed
Jan 2, 2024
This commit introduces the execution functionality in the PhysicalMergeAggregate operator. It provides data procedures for various aggregate functions like COUNT, MIN, MAX, and SUM across different DataTypes. Additionally, proper handling for input and Output dataBlocks has been implemented. Consequently, various changes to the TaskScheduler, code refactoring and logging adjustments were also done.
The PhysicalMergeAggregate operator execution logic has been updated to correctly handle COUNT, MIN, MAX, and SUM aggregate functions for different DataTypes. This commit also implements appropriate handling for input and output dataBlocks. Concurrently, various changes are performed in the TaskScheduler. Several code sections were refactored for better readability and logs have been properly adjusted for detailed tracing.
Deleted several unused template functions in `physical_merge_aggregate.cppm` and `physical_merge_aggregate.cpp`. Also removed a sizable chunk of unused logic related to execution of different aggregate functions from `PhysicalMergeAggregate::SimpleMergeAggregateExecute()` method. This declutters the codebase, making it easier to read and understand.
The PhysicalMergeAggregate class was refactored by introducing a new method, SimpleMergeAggregateExecute, to encapsulate some of the implementation details. The newly defined method simplifies the complexity of the code and makes the execute method easier to understand. ExpressionBinder class was also modified to improve clarity of the division function expression building process, simplifying it and making code more maintainable. Minor tweaks were also made to the fragment_context.cpp file to further enhance readability.
The commit involves converting avg function expressions to (sum / count) function expressions in the SQL planner and test updates accordingly. Tests cover both the regular and exceptional cases. Corresponding changes are reflected in other parts of the code like ProjectBinder and Aggregate operators.
The conversion of AVG function to SUM / COUNT has been refactored for efficiency and readability. A helper function, ConvertAvgToSumDivideCount, has been introduced to modularize this logic. The updated code significantly shrinks the BuildExpression method, improving its maintainability.
Modified the div functions to return results as Double type instead of previous specific integer types. Additionally, adjusted relevant test cases to match the changes. This allows for more accurate division results across the codebase.
A "count(*)" functionality was implemented, enabling users to count the number of rows of SQL tables. Several test scripts were modified to include a "SELECT count(*)" command immediately after table operations to verify the row count. The 'Update' and 'Delete' operations were adjusted in 'table_collection_entry.cpp', and 'StateUpdate' was modified in 'aggregate_function.cppm'. New 'CountStar' related files were added to implement the new functionality.
loloxwg
changed the title
For avg functions replacing it with (sum / count)
For avg functions replacing it with (sum / count), count(*)
Jan 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem does this PR solve?
For avg functions replacing it with (sum / count)
The commit involves converting avg function expressions to (sum / count) function expressions in the SQL planner and test updates accordingly. Tests cover both the regular and exceptional cases. Corresponding changes are reflected in other parts of the code like ProjectBinder and Aggregate operators.
support
count(*)
Issue link: #357
What is changed and how it works?
Code changes
Check List
Tests
Side effects
Note for reviewer