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

min()/max() return wrong results on some collections #6768

Closed
avikivity opened this issue Jul 6, 2020 · 3 comments
Closed

min()/max() return wrong results on some collections #6768

avikivity opened this issue Jul 6, 2020 · 3 comments
Assignees
Labels

Comments

@avikivity
Copy link
Member

cassandra@cqlsh:ks1> create table t (id int primary key, s1 set<int>, s2 set<blob>);
cassandra@cqlsh:ks1> insert into t (id, s1, s2) values (1, {-1, 1}, {0xff, 0x01});
cassandra@cqlsh:ks1> insert into t (id, s1, s2) values (1, {-2, 2}, {0xfe, 0x02});
cassandra@cqlsh:ks1> select max(s1), max(s2) from t;

 system.max(s1) | system.max(s2)
----------------+----------------
        {-2, 2} |   {0x02, 0xfe}

max(s2) is correct, but max(s1) is incorrect.

@avikivity
Copy link
Member Author

All types have comparison functions, so we can just delegate to the type.

jul-stas added a commit to jul-stas/scylladb that referenced this issue Jul 8, 2020
For collections and UDTs the `MIN()` and `MAX()` functions are
generated on the fly. Until now they worked by comparing just the
byte representations of arguments.

This patch uses specific per-type comparators to provide semantically
sensible, dynamically created aggregates.

Fixes scylladb#6768
avikivity added a commit that referenced this issue Jul 8, 2020
…iusz

"
For collections and UDTs the `MIN()` and `MAX()` functions are
generated on the fly. Until now they worked by comparing just the
byte representations of their arguments.

This patch employs specific per-type comparators to provide semantically
sensible, dynamically created aggregates.

Fixes #6768
"

* jul-stas-6768-use-type-comparators-for-minmax:
  tests: Test min/max on set
  aggregate_fcts: Use per-type comparators for dynamic types
avikivity pushed a commit that referenced this issue Aug 3, 2020
For collections and UDTs the `MIN()` and `MAX()` functions are
generated on the fly. Until now they worked by comparing just the
byte representations of arguments.

This patch uses specific per-type comparators to provide semantically
sensible, dynamically created aggregates.

Fixes #6768

(cherry picked from commit 5b438e7)
avikivity pushed a commit that referenced this issue Aug 3, 2020
For collections and UDTs the `MIN()` and `MAX()` functions are
generated on the fly. Until now they worked by comparing just the
byte representations of arguments.

This patch uses specific per-type comparators to provide semantically
sensible, dynamically created aggregates.

Fixes #6768

(cherry picked from commit 5b438e7)
avikivity pushed a commit that referenced this issue Aug 3, 2020
For collections and UDTs the `MIN()` and `MAX()` functions are
generated on the fly. Until now they worked by comparing just the
byte representations of arguments.

This patch uses specific per-type comparators to provide semantically
sensible, dynamically created aggregates.

Fixes #6768

(cherry picked from commit 5b438e7)
@avikivity
Copy link
Member Author

Backported to 4.0, 4.1, 4.2.

@yarongilor
Copy link

the issue description here is probably wrong, using the same PK for 2 inserts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants