mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-29 06:04:06 +00:00
* fix(query): push down PromQL cast filters (#8407) * fix(query): push down PromQL cast filters Signed-off-by: discord9 <discord9@163.com> * test(query): cover cast preimage pushdown Signed-off-by: discord9 <discord9@163.com> * test(query): expand cast preimage coverage Signed-off-by: discord9 <discord9@163.com> * test(query): compare cast normalization rules Signed-off-by: discord9 <discord9@163.com> * test(query): update cast pushdown sqlness plans Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> (cherry picked from commit4f5dccf6bb) * fix: update datafusion-pg-catalog (#8417) (cherry picked from commit434e0c7682) * fix: global limit for distributed inspect streams (#8412) * fix: global limit for distributed inspect streams Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: honor tighter filter fetch under global limit Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: restore distribution after global limit Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: preserve inherited distribution for global limit Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: propagate inherited hash partitioning Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com> (cherry picked from commit5bcc2e9d6b) * feat: update dashboard to v0.13.7 (#8431) (cherry picked from commitebfe4f6eb2) * fix: preserve repartitioned file refs during GC (#8445) * fix: preserve repartitioned file refs during GC Signed-off-by: discord9 <discord9@163.com> * refactor: clarify file refs target region Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> (cherry picked from commit149b687a92) * fix: repartition subset partition key joins (#8460) Signed-off-by: discord9 <discord9@163.com> (cherry picked from commitff2fa71d50) * fix: honor exclusive end in log queries (#8495) * fix: exclude logs end boundary Signed-off-by: discord9 <discord9@163.com> * fix: normalize log query date bounds Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> (cherry picked from commit99235e4b2d) * feat: skip oversized compaction tasks (#8466) fix: skip oversized compaction tasks Signed-off-by: jeremyhi <fengjiachun@gmail.com> (cherry picked from commit0fcf61c3fb) * feat: use scan output bytes for read costing (#8276) * feat: track scan output bytes and use them for read costing Track the actual byte count of each record batch produced by `RegionScanExec` and use it in place of the aggregated per-plan `memory_usage` as the `table_scan` cost input. This avoids double counting bytes that flow through multiple operators. A named constant `REGION_SCAN_EXEC_NAME` exposes the plan node name so downstream metric parsers remain correct if the struct is renamed. Affected files: - `src/table/src/table/metrics.rs` -- add `output_bytes` counter - `src/table/src/table/scan.rs` -- record bytes, export name constant - `src/query/src/dist_plan/merge_scan.rs` -- consume scan bytes Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> * refactor: remove misleading `mem_used` gauge from scan metrics The `mem_used` gauge was used with `add()` on every output batch, but a RegionScan does not hold memory across polls — each batch is yielded immediately to the upstream operator. The gauge semantics were incorrect (cumulative `add()` on a gauge) and the value duplicated `output_bytes` anyway. Affected files: - `src/table/src/table/metrics.rs` — drop `mem_used` field and methods - `src/table/src/table/scan.rs` — remove `record_mem_usage` call Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> * fix: use stable plan names for scan byte metrics Expose `plan_name` alongside rendered plan text so scan byte extraction no longer depends on EXPLAIN formatting. Keep old serialized metrics compatible by defaulting missing `plan_name`. Affected files: - `src/common/recordbatch/src/adapter.rs` -- add `plan_name` to `PlanMetrics` and populate it from `ExecutionPlan::name` - `src/query/src/dist_plan/merge_scan.rs` -- match `REGION_SCAN_EXEC_NAME` through `plan_name` Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> * fix: preserve merge scan CPU read cost Record read cost whenever stream metrics are available, default scan bytes to zero, and aggregate scan output bytes across region scan nodes. Files: `src/query/src/dist_plan/merge_scan.rs` Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> * fix: correct doc comment in `StreamMetrics` Fix doc comment on `StreamMetrics::new()` to reference the correct struct name (`StreamMetrics`) instead of the old `MemoryUsageMetrics`. - `src/table/src/table/metrics.rs` — fix struct name in doc comment Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> --------- Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> (cherry picked from commit4373c77d35) * fix: account logical record batch slice memory (#8480) * fix: account logical record batch slice memory Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: account nested view payload memory Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test: align scan memory expectation with logical size Signed-off-by: jeremyhi <fengjiachun@gmail.com> * refactor: name Arrow inline view limit Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: account visible list child memory Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: exclude null list child memory Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: exclude null struct child memory Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: account fixed-size list slices Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: limit scan accounting to flat slices Signed-off-by: jeremyhi <fengjiachun@gmail.com> * docs: clarify nested view accounting scope Signed-off-by: jeremyhi <fengjiachun@gmail.com> * perf: reduce view memory accounting overhead Signed-off-by: jeremyhi <fengjiachun@gmail.com> * chore: fix benchmark license header Signed-off-by: jeremyhi <fengjiachun@gmail.com> * perf: optimize view slice accounting Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test: cover sliced mixed-null view accounting Signed-off-by: jeremyhi <fengjiachun@gmail.com> * refactor: narrow slice accounting to arrow buffers Signed-off-by: jeremyhi <fengjiachun@gmail.com> * docs: note view accounting assumption Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com> (cherry picked from commit9cde31a647) * fix: preserve distributed topk merge ordering (#8432) * fix: preserve distributed topk for scalar latest Signed-off-by: discord9 <discord9@163.com> * fix: preserve scalar latest ordering across merge scan Signed-off-by: discord9 <discord9@163.com> * fix: carry merge scan ordering from planner rewrite Signed-off-by: discord9 <discord9@163.com> * test: cover merge scan ordering metadata Signed-off-by: discord9 <discord9@163.com> * test: cover merge scan partition ordering gate Signed-off-by: discord9 <discord9@163.com> * fix: require adjacent merge sort for ordering metadata Signed-off-by: discord9 <discord9@163.com> * test: update ordering sqlness plans Signed-off-by: discord9 <discord9@163.com> * fix: preserve distributed topk merge ordering Signed-off-by: discord9 <discord9@163.com> * test: cover latest per series queries Signed-off-by: discord9 <discord9@163.com> * test: update distributed merge sort sqlness Signed-off-by: discord9 <discord9@163.com> * test: cover merge scan ordering partition gate Signed-off-by: discord9 <discord9@163.com> * test: cover merge scan over-partition ordering Signed-off-by: discord9 <discord9@163.com> * test: cover distributed latest with low parallelism Signed-off-by: discord9 <discord9@163.com> * fix: keep distributed merge sort opaque Signed-off-by: discord9 <discord9@163.com> * test: assert distributed scalar latest merge sort Signed-off-by: discord9 <discord9@163.com> * test: clarify merge scan ordering helper Signed-off-by: discord9 <discord9@163.com> * fix: complete merge sort exec delegation Signed-off-by: discord9 <discord9@163.com> * docs: explain merge sort limit pushdown Signed-off-by: discord9 <discord9@163.com> * test: cover merge sort optimizer opacity Signed-off-by: discord9 <discord9@163.com> * docs: explain merge sort optimizer hooks Signed-off-by: discord9 <discord9@163.com> * test: cover merge sort optimizer hooks Signed-off-by: discord9 <discord9@163.com> * fix: preserve merge sort child topk Signed-off-by: discord9 <discord9@163.com> * test: update order by topk plan Signed-off-by: discord9 <discord9@163.com> * fix: recognize merge sort global fetch Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> (cherry picked from commitb30765e5e9) * fix: reject out-of-range PostgreSQL numeric UInt64 (#8517) Signed-off-by: discord9 <discord9@163.com> (cherry picked from commitd48f296144) * fix(log-store): deduplicate Kafka WAL multipart records (#8514) * fix(log-store): deduplicate Kafka WAL multipart records Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(log-store): preserve delayed Kafka WAL entry offsets Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(log-store): reject conflicting Kafka WAL last records Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(log-store): emit Kafka WAL entries on last record Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(log-store): discard duplicate Kafka WAL first records Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> (cherry picked from commit912db22417) * fix: apply log query limit after expressions (#8496) Signed-off-by: discord9 <discord9@163.com> (cherry picked from commit1122d1e7d7) * fix(query): delegate merge sort cardinality effect (#8532) Signed-off-by: discord9 <discord9@163.com> (cherry picked from commit887fdf7513) * fix: upgrade datafusion fork (#8438) Signed-off-by: jeremyhi <fengjiachun@gmail.com> (cherry picked from commitf12a1da3de) * chore: bump version Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: discord9 <discord9@163.com> Signed-off-by: jeremyhi <fengjiachun@gmail.com> Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> Signed-off-by: WenyXu <wenymedia@gmail.com> Co-authored-by: discord9 <discord9@163.com> Co-authored-by: Ning Sun <sunng@protonmail.com> Co-authored-by: jeremyhi <jiachun_feng@proton.me> Co-authored-by: sun <sunchang_long@163.com> Co-authored-by: Lei, HUANG <6406592+v0y4g3r@users.noreply.github.com>
646 lines
17 KiB
Plaintext
646 lines
17 KiB
Plaintext
CREATE TABLE integers(i INTEGER, j TIMESTAMP TIME INDEX);
|
|
|
|
Affected Rows: 0
|
|
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) ORDER BY i;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: integers.i ASC NULLS LAST_|
|
|
|_|_LeftSemi Join: integers.i = __correlated_sq_1.i_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: __correlated_sq_1_|
|
|
|_|_Projection: integers.i_|
|
|
|_|_Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [i@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[i@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: i1.i ASC NULLS LAST_|
|
|
|_|_LeftSemi Join: i1.i = __correlated_sq_1.i_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: i1_|
|
|
|_|_Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: __correlated_sq_1_|
|
|
|_|_Projection: integers.i_|
|
|
|_|_Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [i@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[i@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
create table other (i INTEGER, j TIMESTAMP TIME INDEX);
|
|
|
|
Affected Rows: 0
|
|
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
explain select t.i
|
|
from (
|
|
select * from integers join other on 1=1
|
|
) t
|
|
where t.i is not null
|
|
order by t.i desc;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: t.i DESC NULLS FIRST_|
|
|
|_|_SubqueryAlias: t_|
|
|
|_|_Cross Join:_|
|
|
|_|_Projection: integers.i_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL, Boolean(true)] |
|
|
|_| ]]_|
|
|
|_|_Projection:_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| TableScan: other_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [i@0 DESC]_|
|
|
|_|_SortExec: expr=[i@0 DESC], preserve_partitioning=[true]_|
|
|
|_|_CrossJoinExec_|
|
|
|_|_CoalescePartitionsExec_|
|
|
|_|_ProjectionExec: expr=[i@0 as i]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_ProjectionExec: expr=[]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
INSERT INTO other SELECT i, 2 FROM integers WHERE i=(SELECT MAX(i) FROM integers);
|
|
|
|
Affected Rows: 0
|
|
|
|
-- Explain physical plan for DML is not supported because it looks up the table name in a way that is
|
|
-- different from normal queries. It also requires the table provider to implement the `insert_into()` method.
|
|
EXPLAIN INSERT INTO other SELECT i, 2 FROM integers WHERE i=(SELECT MAX(i) FROM integers);
|
|
|
|
+---------------------+-----------------------------------------------------------------------------+
|
|
| plan_type | plan |
|
|
+---------------------+-----------------------------------------------------------------------------+
|
|
| logical_plan | Dml: op=[Insert Into] table=[other] |
|
|
| | Projection: integers.i AS i, TimestampMillisecond(2, None) AS j |
|
|
| | Inner Join: integers.i = __scalar_sq_1.max(integers.i) |
|
|
| | Projection: integers.i |
|
|
| | MergeScan [is_placeholder=false, remote_input=[ |
|
|
| | TableScan: integers |
|
|
| | ]] |
|
|
| | MergeScan [is_placeholder=false, remote_input=[ |
|
|
| | SubqueryAlias: __scalar_sq_1 |
|
|
| | Projection: max(integers.i) |
|
|
| | Aggregate: groupBy=[[]], aggr=[[max(integers.i)]] |
|
|
| | TableScan: integers, partial_filters=[Boolean(true)] |
|
|
| | ]] |
|
|
| physical_plan_error | This feature is not implemented: Insert into not implemented for this table |
|
|
+---------------------+-----------------------------------------------------------------------------+
|
|
|
|
drop table other;
|
|
|
|
Affected Rows: 0
|
|
|
|
drop table integers;
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE integers(i INTEGER, j TIMESTAMP TIME INDEX)
|
|
PARTITION ON COLUMNS (i) (
|
|
i < 1000,
|
|
i >= 1000 AND i < 2000,
|
|
i >= 2000
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: i1.i ASC NULLS LAST_|
|
|
|_|_LeftSemi Join: i1.i = __correlated_sq_1.i_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: i1_|
|
|
|_|_Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: __correlated_sq_1_|
|
|
|_|_Projection: integers.i_|
|
|
|_|_Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [i@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[i@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT * FROM integers i1 WHERE EXISTS(SELECT count(i) FROM integers WHERE i=i1.i) ORDER BY i1.i;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: i1.i ASC NULLS LAST_|
|
|
|_|_LeftSemi Join: i1.i = __correlated_sq_1.i_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: i1_|
|
|
|_|_Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
|_|_Projection: __correlated_sq_1.i_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: __correlated_sq_1_|
|
|
|_|_Projection: count(integers.i), integers.i_|
|
|
|_|_Aggregate: groupBy=[[integers.i]], aggr=[[count(integers.i)]]_|
|
|
|_|_Filter: integers.i IS NOT NULL_|
|
|
|_|_TableScan: integers, partial_filters=[integers.i IS NOT NULL]_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [i@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[i@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_ProjectionExec: expr=[i@1 as i]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
DROP TABLE integers;
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE t(ts timestamp time index, a INT, b INT)PARTITION ON COLUMNS (a) (
|
|
a < 1000,
|
|
a >= 1000 AND a < 2000,
|
|
a >= 2000
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE t1(ts timestamp time index, a INT)PARTITION ON COLUMNS (a) (
|
|
a < 1000,
|
|
a >= 1000 AND a < 2000,
|
|
a >= 2000
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE t2(ts timestamp time index, a INT)PARTITION ON COLUMNS (a) (
|
|
a < 1000,
|
|
a >= 1000 AND a < 2000,
|
|
a >= 2000
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO t(ts,a,b) VALUES (1,3,30),(2,1,10),(3,2,20);
|
|
|
|
Affected Rows: 3
|
|
|
|
INSERT INTO t1(ts,a) VALUES (1,1),(2,3);
|
|
|
|
Affected Rows: 2
|
|
|
|
INSERT INTO t2(ts,a) VALUES (1,2),(2,3);
|
|
|
|
Affected Rows: 2
|
|
|
|
SELECT x FROM (SELECT a AS x FROM t) sq ORDER BY x;
|
|
|
|
+---+
|
|
| x |
|
|
+---+
|
|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
+---+
|
|
|
|
-- expected: 1,2,3
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT x FROM (SELECT a AS x FROM t) sq ORDER BY x;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| MergeSort: sq.x ASC NULLS LAST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Sort: sq.x ASC NULLS LAST_|
|
|
|_|_Projection: sq.x_|
|
|
|_|_SubqueryAlias: sq_|
|
|
|_|_Projection: t.a AS x_|
|
|
|_|_TableScan: t_|
|
|
|_| ]]_|
|
|
| physical_plan | MergeSortExec: [x@0 ASC NULLS LAST]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT x, COUNT(*) AS c FROM (SELECT a AS x FROM t) sq GROUP BY x ORDER BY x;
|
|
|
|
+---+---+
|
|
| x | c |
|
|
+---+---+
|
|
| 1 | 1 |
|
|
| 2 | 1 |
|
|
| 3 | 1 |
|
|
+---+---+
|
|
|
|
-- expected:
|
|
-- x | c
|
|
-- 1 | 1
|
|
-- 2 | 1
|
|
-- 3 | 1
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT x, COUNT(*) AS c FROM (SELECT a AS x FROM t) sq GROUP BY x ORDER BY x;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| MergeSort: sq.x ASC NULLS LAST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Sort: sq.x ASC NULLS LAST_|
|
|
|_|_Projection: sq.x, count(Int64(1)) AS count(*) AS c_|
|
|
|_|_Aggregate: groupBy=[[sq.x]], aggr=[[count(Int64(1))]]_|
|
|
|_|_SubqueryAlias: sq_|
|
|
|_|_Projection: t.a AS x_|
|
|
|_|_TableScan: t_|
|
|
|_| ]]_|
|
|
| physical_plan | MergeSortExec: [x@0 ASC NULLS LAST]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT DISTINCT x FROM (SELECT a AS x FROM t) sq ORDER BY x;
|
|
|
|
+---+
|
|
| x |
|
|
+---+
|
|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
+---+
|
|
|
|
-- expecetd: 1,2,3
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT DISTINCT x FROM (SELECT a AS x FROM t) sq ORDER BY x;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: sq.x ASC NULLS LAST_|
|
|
|_|_Aggregate: groupBy=[[sq.x]], aggr=[[]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Distinct:_|
|
|
|_|_Projection: sq.x_|
|
|
|_|_SubqueryAlias: sq_|
|
|
|_|_Projection: t.a AS x_|
|
|
|_|_TableScan: t_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [x@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[x@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_AggregateExec: mode=SinglePartitioned, gby=[x@0 as x], aggr=[]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT sq.x FROM (SELECT a AS x FROM t) sq ORDER BY sq.x;
|
|
|
|
+---+
|
|
| x |
|
|
+---+
|
|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
+---+
|
|
|
|
-- expected: 1,2,3
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT sq.x FROM (SELECT a AS x FROM t) sq ORDER BY sq.x;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| MergeSort: sq.x ASC NULLS LAST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Sort: sq.x ASC NULLS LAST_|
|
|
|_|_Projection: sq.x_|
|
|
|_|_SubqueryAlias: sq_|
|
|
|_|_Projection: t.a AS x_|
|
|
|_|_TableScan: t_|
|
|
|_| ]]_|
|
|
| physical_plan | MergeSortExec: [x@0 ASC NULLS LAST]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT y FROM (SELECT x AS y FROM (SELECT a AS x FROM t) sq1) sq2 ORDER BY y;
|
|
|
|
+---+
|
|
| y |
|
|
+---+
|
|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
+---+
|
|
|
|
-- expected: 1,2,3
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT y FROM (SELECT x AS y FROM (SELECT a AS x FROM t) sq1) sq2 ORDER BY y;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| MergeSort: sq2.y ASC NULLS LAST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Sort: sq2.y ASC NULLS LAST_|
|
|
|_|_Projection: sq2.y_|
|
|
|_|_SubqueryAlias: sq2_|
|
|
|_|_Projection: sq1.x AS y_|
|
|
|_|_SubqueryAlias: sq1_|
|
|
|_|_Projection: t.a AS x_|
|
|
|_|_TableScan: t_|
|
|
|_| ]]_|
|
|
| physical_plan | MergeSortExec: [y@0 ASC NULLS LAST]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT x, x + 1 AS y FROM (SELECT a AS x FROM t) sq ORDER BY x;
|
|
|
|
+---+---+
|
|
| x | y |
|
|
+---+---+
|
|
| 1 | 2 |
|
|
| 2 | 3 |
|
|
| 3 | 4 |
|
|
+---+---+
|
|
|
|
-- expected:
|
|
-- (x,y)
|
|
-- (1,2)
|
|
-- (2,3)
|
|
-- (3,4)
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT x, x + 1 AS y FROM (SELECT a AS x FROM t) sq ORDER BY x;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| MergeSort: sq.x ASC NULLS LAST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Sort: sq.x ASC NULLS LAST_|
|
|
|_|_Projection: sq.x, CAST(sq.x AS Int64) + Int64(1) AS y_|
|
|
|_|_SubqueryAlias: sq_|
|
|
|_|_Projection: t.a AS x_|
|
|
|_|_TableScan: t_|
|
|
|_| ]]_|
|
|
| physical_plan | MergeSortExec: [x@0 ASC NULLS LAST]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT a FROM ((SELECT a FROM t1) UNION ALL (SELECT a FROM t2)) u ORDER BY a;
|
|
|
|
+---+
|
|
| a |
|
|
+---+
|
|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 3 |
|
|
+---+
|
|
|
|
-- expected: 1,2,3,3
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT a FROM ((SELECT a FROM t1) UNION ALL (SELECT a FROM t2)) u ORDER BY a;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: u.a ASC NULLS LAST_|
|
|
|_|_SubqueryAlias: u_|
|
|
|_|_Union_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Projection: t1.a_|
|
|
|_|_TableScan: t1_|
|
|
|_| ]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Projection: t2.a_|
|
|
|_|_TableScan: t2_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [a@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[a@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_InterleaveExec_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT u1.a
|
|
FROM (SELECT a FROM t1) u1
|
|
JOIN (SELECT a FROM t2) u2 ON u1.a = u2.a
|
|
ORDER BY u1.a;
|
|
|
|
+---+
|
|
| a |
|
|
+---+
|
|
| 3 |
|
|
+---+
|
|
|
|
-- expected: 3
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT u1.a
|
|
FROM (SELECT a FROM t1) u1
|
|
JOIN (SELECT a FROM t2) u2 ON u1.a = u2.a
|
|
ORDER BY u1.a;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: u1.a ASC NULLS LAST_|
|
|
|_|_Projection: u1.a_|
|
|
|_|_Inner Join: u1.a = u2.a_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: u1_|
|
|
|_|_Projection: t1.a_|
|
|
|_|_Filter: t1.a IS NOT NULL_|
|
|
|_|_TableScan: t1, partial_filters=[t1.a IS NOT NULL]_|
|
|
|_| ]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| SubqueryAlias: u2_|
|
|
|_|_Projection: t2.a_|
|
|
|_|_Filter: t2.a IS NOT NULL_|
|
|
|_|_TableScan: t2, partial_filters=[t2.a IS NOT NULL]_|
|
|
|_| ]]_|
|
|
| physical_plan | SortPreservingMergeExec: [a@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[a@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT x FROM (VALUES (2),(1)) v(x) ORDER BY x;
|
|
|
|
+---+
|
|
| x |
|
|
+---+
|
|
| 1 |
|
|
| 2 |
|
|
+---+
|
|
|
|
-- expected: 1,2
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT x FROM (VALUES (2),(1)) v(x) ORDER BY x;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Sort: v.x ASC NULLS LAST_|
|
|
|_|_SubqueryAlias: v_|
|
|
|_|_Projection: column1 AS x_|
|
|
|_|_Values: (Int64(2)), (Int64(1))_|
|
|
| physical_plan | SortExec: expr=[x@0 ASC NULLS LAST], preserve_partitioning=[false] |
|
|
|_|_ProjectionExec: expr=[column1@0 as x]_|
|
|
|_|_DataSourceExec: partitions=1, partition_sizes=[1]_|
|
|
|_|_|
|
|
+-+-+
|
|
|
|
SELECT x FROM (SELECT a AS x FROM t) sq ORDER BY x LIMIT 2;
|
|
|
|
+---+
|
|
| x |
|
|
+---+
|
|
| 1 |
|
|
| 2 |
|
|
+---+
|
|
|
|
-- expected: 1,2
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
EXPLAIN SELECT x FROM (SELECT a AS x FROM t) sq ORDER BY x LIMIT 2;
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Limit: skip=0, fetch=2_|
|
|
|_|_MergeSort: sq.x ASC NULLS LAST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Limit: skip=0, fetch=2_|
|
|
|_|_Sort: sq.x ASC NULLS LAST_|
|
|
|_|_Projection: sq.x_|
|
|
|_|_SubqueryAlias: sq_|
|
|
|_|_Projection: t.a AS x_|
|
|
|_|_TableScan: t_|
|
|
|_| ]]_|
|
|
| physical_plan | MergeSortExec: [x@0 ASC NULLS LAST], fetch=2_|
|
|
|_|_SortExec: TopK(fetch=2), expr=[x@0 ASC NULLS LAST], preserve_partitioning=[true]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
DROP TABLE t;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE t1;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE t2;
|
|
|
|
Affected Rows: 0
|
|
|