Fix predicates optimization for distributed queries with HAVING#10621
Conversation
feaab52 to
df9fecd
Compare
e8104d14aa |
src/Interpreters/Aggregator.cpp
Outdated
There was a problem hiding this comment.
cc: @alexey-milovidov
I think this is an unnecessary change, and the change predicates order should be reasonable.
We keep it so that we can continue to find same bugs.
There was a problem hiding this comment.
I don't have any strong arguments, but executing different queries on the initiator and remote shards (even if only the order differs) sounds tricky
But catching some possible issues maybe a good argument to ignore trickery
|
Check failures looks like due to problems on CI |
|
Friendly ping |
e8104d1 to
a4957e7
Compare
|
Test report summary:
|
…optimize_predicate_expression) Before this patch enable_optimize_predicate_expression changes the order *every* time, so: foo AND bar -> bar AND foo And this causes troubles for distributed queries, since query on shard will have different order of expressions with the initiating server.
Relax this to allow accepting aggregate keys in different order (typical use case is distributed queries, where the initiator server will do final merge).
a4957e7 to
6a9ec13
Compare
|
Looks like some tests stuck?
Everything else is green (including performance) |
|
@alexey-milovidov can you take a look? |
|
Ok. |
|
This pr also fixes #11413 |
…ion-order Fix predicates optimization for distributed queries with HAVING (cherry picked from commit a8f5b10)
…ion-order Fix predicates optimization for distributed queries with HAVING (cherry picked from commit a8f5b10)
…ion-order Fix predicates optimization for distributed queries with HAVING (cherry picked from commit a8f5b10)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix predicates optimization for distributed queries (
enable_optimize_predicate_expression=1) for queries withHAVINGsection (i.e. when filtering on the server initiator is required), by preserving the order of expressions (and this is enough to fix), and also force aggregator use column names over indexes. Fixes: #10613, #11413Details:
The problem is that server initiator need to do final aggregate, but Aggregator works based on column indexes, and since expression optimizer switch it every time, server initiator will have different order of columns with the results from the shards that it needs to aggregate, I'm looking into make Aggregator respect column names (if that makes sense?), but will take some time
Cc: @zhang2014