Skip to content
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

Allow Aggregations in Case Expressions #12613

Merged

Conversation

ege-st
Copy link
Contributor

@ege-st ege-st commented Mar 10, 2024

(Bugfix)

In Calcite, this removes the check that prevents aggregation functions from being used within a Case/When expression in the V1 engine.

Testing:

  1. Added a unit test for V2 engine
  2. Validated locally with Pinot running the query: select AirlineID, (CASE WHEN sum(ActualElapsedTime) > 0 THEN sum(ActualElapsedTime) ELSE 0 END) AS cpm from airlineStats group by AirlineID and comparing the results between V1 and V2 engine.

@ege-st
Copy link
Contributor Author

ege-st commented Mar 10, 2024

Could not find the right place to put a V1 engine unit test for this change, so please let me know where it should go.

Comment on lines +109 to +110
new Object[]{"SELECT a.col1, CASE WHEN sum(a.col3) = 0 THEN 0 ELSE SUM(a.col3) END AS match_sum "
+ " FROM a WHERE a.ts >= 1600000000 GROUP BY a.col1"},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to add additional unit tests for V2 as I think this test just verifies Semantics and Syntax, would like to test execution results.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we want to add tests for V1. It is already working in V2

@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.86%. Comparing base (59551e4) to head (e38fe4c).
Report is 118 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12613      +/-   ##
============================================
+ Coverage     61.75%   61.86%   +0.10%     
+ Complexity      207      198       -9     
============================================
  Files          2436     2453      +17     
  Lines        133233   133827     +594     
  Branches      20636    20752     +116     
============================================
+ Hits          82274    82786     +512     
- Misses        44911    44925      +14     
- Partials       6048     6116      +68     
Flag Coverage Δ
custom-integration1 <0.01% <ø> (-0.01%) ⬇️
integration <0.01% <ø> (-0.01%) ⬇️
integration1 <0.01% <ø> (-0.01%) ⬇️
integration2 0.00% <ø> (ø)
java-11 61.76% <ø> (+0.05%) ⬆️
java-21 61.72% <ø> (+0.10%) ⬆️
skip-bytebuffers-false 61.84% <ø> (+0.09%) ⬆️
skip-bytebuffers-true 61.64% <ø> (+33.91%) ⬆️
temurin 61.86% <ø> (+0.10%) ⬆️
unittests 61.85% <ø> (+0.10%) ⬆️
unittests1 46.95% <ø> (+0.06%) ⬆️
unittests2 27.73% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ege-st
Copy link
Contributor Author

ege-st commented Mar 12, 2024 via email

@Jackie-Jiang
Copy link
Contributor

You may add some queries in BaseClusterIntegrationTestSet.testHardcodedQueries() which can apply to both V1 and V2

@ege-st
Copy link
Contributor Author

ege-st commented Mar 12, 2024 via email

@Jackie-Jiang Jackie-Jiang reopened this Mar 12, 2024
@Jackie-Jiang Jackie-Jiang merged commit e7220fa into apache:master Mar 12, 2024
18 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants