Skip to content

Commit

Permalink
feat: support push down IN filter (#5129)
Browse files Browse the repository at this point in the history
* feat: support push down IN filter

* chore: move tests to prune.sql
  • Loading branch information
NiwakaDev authored Dec 11, 2024
1 parent 60f8dbf commit a801214
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/query/src/dist_plan/commutativity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl Categorizer {
| Expr::Between(_)
| Expr::Sort(_)
| Expr::Exists(_)
| Expr::InList(_)
| Expr::ScalarFunction(_) => Commutativity::Commutative,

Expr::Like(_)
Expand All @@ -157,7 +158,6 @@ impl Categorizer {
| Expr::TryCast(_)
| Expr::AggregateFunction(_)
| Expr::WindowFunction(_)
| Expr::InList(_)
| Expr::InSubquery(_)
| Expr::ScalarSubquery(_)
| Expr::Wildcard { .. } => Commutativity::Unimplemented,
Expand Down
26 changes: 26 additions & 0 deletions tests/cases/standalone/common/select/prune.result
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@ explain analyze select * from demo where idc='idc1';
|_|_| Total rows: 2_|
+-+-+-+

SELECT * FROM demo where host in ('test1');

+-------------------------+-------+-------+------+-----------+
| ts | value | host | idc | collector |
+-------------------------+-------+-------+------+-----------+
| 1970-01-01T00:00:00.001 | 2.0 | test1 | idc1 | disk |
+-------------------------+-------+-------+------+-----------+

-- SQLNESS REPLACE (metrics.*) REDACTED
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
-- SQLNESS REPLACE (-+) -
-- SQLNESS REPLACE (\s\s+) _
-- SQLNESS REPLACE (peers.*) REDACTED
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
explain analyze SELECT * FROM demo where host in ('test1');

+-+-+-+
| stage | node | plan_|
+-+-+-+
| 0_| 0_|_MergeScanExec: REDACTED
|_|_|_|
| 1_| 0_|_SeqScan: region=REDACTED, partition_count=1 (1 memtable ranges, 0 file 0 ranges) REDACTED
|_|_|_|
|_|_| Total rows: 1_|
+-+-+-+

drop table demo;

Affected Rows: 0
Expand Down
10 changes: 10 additions & 0 deletions tests/cases/standalone/common/select/prune.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ select * from demo where collector='disk' order by ts;
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
explain analyze select * from demo where idc='idc1';

SELECT * FROM demo where host in ('test1');

-- SQLNESS REPLACE (metrics.*) REDACTED
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
-- SQLNESS REPLACE (-+) -
-- SQLNESS REPLACE (\s\s+) _
-- SQLNESS REPLACE (peers.*) REDACTED
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
explain analyze SELECT * FROM demo where host in ('test1');

drop table demo;

0 comments on commit a801214

Please sign in to comment.