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

Correctly delegate BitColumnExpression::eval(*double out, bool& missing) #144

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

TomHodson
Copy link
Contributor

The Problem

When an odc sql statement includes both aggregate functions and bitfield columns, the bitfield columns are not printed (or aggregated) correctly.

>>> odc sql -i odc/docs/_static/data-1.odb -q "select avg(bitfield_column.flag_a),bitfield_column.flag_a,bitfield_column.flag_b"
avg(bitfield_column.flag_a)     bitfield_column.flag_a  bitfield_column.flag_b
                   0.000000                          0                       0
                   1.000000                        111                     111
                   0.000000                        222                     222
                   1.000000                        333                     333
                   0.000000                        444                     444
                   1.000000                        555                     555
                   0.000000                        666                     666
                   1.000000                        777                     777
                   0.000000                        888                     888
                   1.000000                        999                     999

The Fix

In the original code, on the code path where we mix aggregated and non-aggregated columns, SQLExpressionEvaluated callse.eval(&value_[0], missing_); whihc, when e is a bitfield column would actually call ColumnExpression::eval(*double out, bool& missing) which does not delegate to BitColumnExpression::eval(bool& missing)

This change overrides BitColumnExpression::eval(*double out, bool& missing) to use SQLExpression:eval(*double out, bool& missing) which correctly delegates to BitColumnExpression::eval(bool& missing).

After this fix:

avg(bitfield_column.flag_a)     bitfield_column.flag_a  bitfield_column.flag_b
                   0.000000                          0                       0
                   0.000000                          0                       1
                   0.000000                          0                       2
                   0.000000                          0                       3
                   1.000000                          1                       0
                   1.000000                          1                       1
                   1.000000                          1                       2
                   1.000000                          1                       3

In the old code calling `e.eval(&value_[0], missing_);` when e was a bitfield would actually call ColumnExpression::eval(*double out, bool& missing) and it wouldn't delegate to BitColumnExpression::eval(bool& missing)

This change overrides BitColumnExpression::eval(*double out, bool& missing) to SQLExpression:eval(*double out, bool& missing) which correctly delegates to BitColumnExpression::eval(bool& missing)
@FussyDuck
Copy link

FussyDuck commented Oct 23, 2024

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 63.76%. Comparing base (e29a620) to head (0e9a5ff).

Files with missing lines Patch % Lines
src/eckit/sql/expression/BitColumnExpression.h 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #144   +/-   ##
========================================
  Coverage    63.75%   63.76%           
========================================
  Files         1065     1066    +1     
  Lines        55342    55345    +3     
  Branches      4085     4085           
========================================
+ Hits         35286    35288    +2     
- Misses       20056    20057    +1     

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

@simondsmart
Copy link
Contributor

Thanks Tom. That looks good.
Please check what the downstream failures are. Otherwise this looks mergeable.

@simondsmart simondsmart merged commit 4550f54 into develop Oct 23, 2024
190 of 199 checks passed
@simondsmart simondsmart deleted the fix/aggregate_functions_break_bitfields branch October 23, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants