diff --git a/tests/sqllogictests/suites/mode/standalone/ee/explain_agg_index.test b/tests/sqllogictests/suites/mode/standalone/ee/explain_agg_index.test index 284f963524e67..4f9068949760d 100644 --- a/tests/sqllogictests/suites/mode/standalone/ee/explain_agg_index.test +++ b/tests/sqllogictests/suites/mode/standalone/ee/explain_agg_index.test @@ -289,6 +289,54 @@ EvalScalar ├── rewritten query: [selection: [index_col_0 (#0)]] └── estimated rows: 0.00 +# for sync aggregating index + +statement ok +SET enable_refresh_aggregating_index_after_write=1; + +statement ok +DROP AGGREGATING INDEX idx1 + +statement ok +CREATE SYNC AGGREGATING INDEX idx1 AS SELECT a + 1 from t1 + +statement ok +INSERT INTO t1 VALUES (1,1), (1,2), (2,4), (2,5) + +query T +EXPLAIN SELECT avg(a + 1) from t1 +---- +EvalScalar +├── output columns: [(sum((a + 1)) / if((count((a + 1)) = 0), 1, count((a + 1)))) (#5)] +├── expressions: [sum((a + 1)) (#3) / CAST(if(CAST(count((a + 1)) (#4) = 0 AS Boolean NULL), 1, count((a + 1)) (#4)) AS UInt64 NULL)] +├── estimated rows: 1.00 +└── AggregateFinal + ├── output columns: [sum((a + 1)) (#3), count((a + 1)) (#4)] + ├── group by: [] + ├── aggregate functions: [sum(sum_arg_0), count()] + ├── estimated rows: 1.00 + └── AggregatePartial + ├── output columns: [sum((a + 1)) (#3), count((a + 1)) (#4)] + ├── group by: [] + ├── aggregate functions: [sum(sum_arg_0), count()] + ├── estimated rows: 1.00 + └── EvalScalar + ├── output columns: [sum_arg_0 (#2)] + ├── expressions: [t1.a (#0) + 1] + ├── estimated rows: 4.00 + └── TableScan + ├── table: default.test_index_db.t1 + ├── output columns: [a (#0)] + ├── read rows: 4 + ├── read bytes: 47 + ├── partitions total: 1 + ├── partitions scanned: 1 + ├── pruning stats: [segments: , blocks: ] + ├── push downs: [filters: [], limit: NONE] + ├── aggregating index: [SELECT (a + 1) FROM test_index_db.t1] + ├── rewritten query: [selection: [index_col_0 (#0)]] + └── estimated rows: 4.00 + # Should not be rewritten query T EXPLAIN SELECT b, a + 1 as x from t1 order by x @@ -296,20 +344,21 @@ EXPLAIN SELECT b, a + 1 as x from t1 order by x Sort ├── output columns: [t1.b (#1), x (#2)] ├── sort keys: [x ASC NULLS LAST] -├── estimated rows: 0.00 +├── estimated rows: 4.00 └── EvalScalar ├── output columns: [t1.b (#1), x (#2)] ├── expressions: [t1.a (#0) + 1] - ├── estimated rows: 0.00 + ├── estimated rows: 4.00 └── TableScan ├── table: default.test_index_db.t1 ├── output columns: [a (#0), b (#1)] - ├── read rows: 0 - ├── read bytes: 0 - ├── partitions total: 0 - ├── partitions scanned: 0 + ├── read rows: 4 + ├── read bytes: 94 + ├── partitions total: 1 + ├── partitions scanned: 1 + ├── pruning stats: [segments: , blocks: ] ├── push downs: [filters: [], limit: NONE] - └── estimated rows: 0.00 + └── estimated rows: 4.00 statement ok DROP AGGREGATING INDEX idx1