mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 05:12:54 +00:00
* apply rewriter to subquery exprs Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * workaround for datafusion's check Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * clean up Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add sqlness test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix typo Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * change time index type Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
132 lines
4.5 KiB
Plaintext
132 lines
4.5 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 (peer-.*) 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]_|
|
|
|_|_SubqueryAlias: __correlated_sq_1_|
|
|
|_|_MergeScan [is_placeholder=false]_|
|
|
| physical_plan | SortPreservingMergeExec: [i@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[i@0 ASC NULLS LAST]_|
|
|
|_|_CoalesceBatchesExec: target_batch_size=8192_|
|
|
|_|_REDACTED
|
|
|_|_CoalesceBatchesExec: target_batch_size=8192_|
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_MergeScanExec: peers=[REDACTED
|
|
|_|_CoalesceBatchesExec: target_batch_size=8192_|
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_MergeScanExec: peers=[REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
|
-- SQLNESS REPLACE (Hash.*) REDACTED
|
|
-- SQLNESS REPLACE (peer-.*) 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_|
|
|
|_|_SubqueryAlias: i1_|
|
|
|_|_MergeScan [is_placeholder=false]_|
|
|
|_|_SubqueryAlias: __correlated_sq_1_|
|
|
|_|_Projection: integers.i_|
|
|
|_|_MergeScan [is_placeholder=false]_|
|
|
| physical_plan | SortPreservingMergeExec: [i@0 ASC NULLS LAST]_|
|
|
|_|_SortExec: expr=[i@0 ASC NULLS LAST]_|
|
|
|_|_CoalesceBatchesExec: target_batch_size=8192_|
|
|
|_|_REDACTED
|
|
|_|_CoalesceBatchesExec: target_batch_size=8192_|
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_MergeScanExec: peers=[REDACTED
|
|
|_|_CoalesceBatchesExec: target_batch_size=8192_|
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_ProjectionExec: expr=[i@0 as i]_|
|
|
|_|_MergeScanExec: peers=[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 (peer-.*) 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_|
|
|
|_|_Inner Join:_|
|
|
|_|_Projection:_|
|
|
|_|_MergeScan [is_placeholder=false]_|
|
|
|_|_Filter: other.i IS NOT NULL_|
|
|
|_|_Projection: other.i_|
|
|
|_|_MergeScan [is_placeholder=false]_|
|
|
| physical_plan | SortExec: expr=[i@0 DESC]_|
|
|
|_|_NestedLoopJoinExec: join_type=Inner_|
|
|
|_|_ProjectionExec: expr=[]_|
|
|
|_|_MergeScanExec: peers=[REDACTED
|
|
|_|_CoalescePartitionsExec_|
|
|
|_|_CoalesceBatchesExec: target_batch_size=8192_|
|
|
|_|_FilterExec: i@0 IS NOT NULL_|
|
|
|_|_RepartitionExec: partitioning=REDACTED
|
|
|_|_ProjectionExec: expr=[i@0 as i]_|
|
|
|_|_MergeScanExec: peers=[REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
EXPLAIN INSERT INTO other SELECT i, 2 FROM integers WHERE i=(SELECT MAX(i) FROM integers);
|
|
|
|
+--------------+-------------------------------------------------------------------+
|
|
| plan_type | plan |
|
|
+--------------+-------------------------------------------------------------------+
|
|
| logical_plan | Dml: op=[Insert] 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] |
|
|
| | SubqueryAlias: __scalar_sq_1 |
|
|
| | Aggregate: groupBy=[[]], aggr=[[MAX(integers.i)]] |
|
|
| | Projection: integers.i |
|
|
| | MergeScan [is_placeholder=false] |
|
|
+--------------+-------------------------------------------------------------------+
|
|
|
|
drop table other;
|
|
|
|
Affected Rows: 1
|
|
|
|
drop table integers;
|
|
|
|
Affected Rows: 1
|
|
|