Skip to content

sumMapFiltered aggregate function wrong result starting from 23.11 #58741

Closed

Description

@alsugiliazova
SELECT sumMapFiltered([6.7])([x],[y]) FROM values('x Float64, y Float64', (0, 1), (1, 2.3), (nan,inf), (6.7,3), (4,4), (5, 1))

Before 23.11:

([6.7],[3])

Starting from 23.11:

 ([nan],[inf])

Activity

  1. added
    potential bug
    on Jan 12, 2024
  2. added
    bug
    and removed
    potential bug
    on Jan 18, 2024
  3. Algunenano commented on Jan 18, 2024

    @Algunenano
    Member

    This was introduced in #56350.

    std::set does not work

  4. Algunenano commented on Jan 18, 2024

    @Algunenano
    Member

    Correction: std::set<DB::Field> does not work as expected because it does not deal with NaN correctly.

    • 5.0 < NaN: False
    • NaN < 5.0 : False
    • Conclusion: 5 == 'NaN'
  5. self-assigned this
    on Jan 18, 2024
  6. davenger commented on Jan 18, 2024

    @davenger
    Member
  7. Algunenano commented on Jan 19, 2024

    @Algunenano
    Member

    do we have the same problem here wit std::map<Field, ...>

    Nice question. And yes, but in this case the bug was already present before the the refactor (since forever, or at least since 20.8 which is the oldest I have around):

    SELECT sumMap([x], [y])
    FROM values('x Float64, y Float64', (4, 1), (1, 2.3), (nan, inf), (6.7, 3), (4, 4), (5, 1))
    
    Query id: 34f31c01-cd59-45d1-a7d0-a8cc93e70f8e
    
    ┌─sumMap(array(x), array(y))─┐
    │ ([1,4,5,6.7],[inf,5,1,3])  │
    └────────────────────────────┘
    
    1 row in set. Elapsed: 0.002 sec.
    

    I have zero trust in this function TBH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions