Fix monotonic chain for read-in-order as well.

This commit is contained in:
Nikolai Kochetov 2023-07-17 18:02:02 +00:00 committed by Amos Bird
parent 60488e2391
commit d7bb006c23
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 17 additions and 1 deletions

View File

@ -75,7 +75,12 @@ MatchedTrees::Matches matchTrees(const ActionsDAG & inner_dag, const ActionsDAG
}
/// A node from found match may be nullptr.
/// It means that node is visited, but no match was found.
if (it->second.monotonicity)
/// Ignore a match with monotonicity.
frame.mapped_children.push_back(nullptr);
else
frame.mapped_children.push_back(it->second.node);
}
if (frame.mapped_children.size() < frame.node->children.size())

View File

@ -1,4 +1,5 @@
DROP TABLE IF EXISTS t0;
DROP TABLE IF EXISTS t1;
CREATE TABLE t0 (c0 Int16, projection h (SELECT min(c0), max(c0), count() GROUP BY -c0)) ENGINE = MergeTree ORDER BY ();
@ -6,4 +7,10 @@ INSERT INTO t0(c0) VALUES (1);
SELECT count() FROM t0 GROUP BY gcd(-sign(c0), -c0);
create table t1 (c0 Int32) engine = MergeTree order by sin(c0);
insert into t1 values (-1), (1);
select c0 from t1 order by sin(-c0) settings optimize_read_in_order=0;
select c0 from t1 order by sin(-c0) settings optimize_read_in_order=1;
DROP TABLE t0;
DROP TABLE t1;