Skip to content

Commit 759c03a

Browse files
committed
Lint
1 parent 1b6ea30 commit 759c03a

2 files changed

Lines changed: 33 additions & 41 deletions

File tree

core/src/test/resources/sql/rule/misc-rules.iq

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ LogicalProject(EMPNO=[$0])
6363
# a subquery (result should be unchanged).
6464

6565
select deptno from sales.emp where
66-
exists (select deptno from sales.emp where empno < 20)
67-
;
66+
exists (select deptno from sales.emp where empno < 20);
6867
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
6968
LogicalFilter(condition=[EXISTS({
7069
LogicalFilter(condition=[<($0, 20)])
@@ -128,11 +127,6 @@ LogicalProject(DEPTNO=[$0])
128127
# testLoptOptimizeJoinRulePrioritizeSelfJoin -----------------------------------
129128
# MULTI_JOIN_OPTIMIZE prioritizes joining emp with itself (self-join) before
130129
# joining with dept.
131-
# TODO: The original Java test applied JOIN_TO_MULTI_JOIN via a HepProgram with
132-
# HepMatchOrder.BOTTOM_UP, which is not expressible in .iq format. With BOTTOM_UP,
133-
# the rule fires on the inner join first, producing nested 2-way MultiJoins rather
134-
# than a flat 3-way MultiJoin. The .iq runner produces the same nested structure
135-
# (BOTTOM_UP appears to be the default for the SubPlanCommand runner).
136130

137131
select e.empno from emp e inner join dept d on d.deptno = e.deptno inner join emp e2 on e.empno = e2.empno;
138132
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
@@ -157,8 +151,7 @@ LogicalProject(EMPNO=[$0])
157151
# contains a subquery (result should be unchanged).
158152

159153
select exists (select deptno from sales.emp)
160-
from (select deptno from sales.emp where empno < 20)
161-
;
154+
from (select deptno from sales.emp where empno < 20);
162155
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
163156
LogicalProject(EXPR$0=[EXISTS({
164157
LogicalTableScan(table=[[CATALOG, SALES, EMP]])

core/src/test/resources/sql/rule/reduce-expressions.iq

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ SELECT *
4343
FROM (VALUES (NULL, 0), (1, NULL), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (3, 4)) AS t1(k, t)
4444
ASOF JOIN (VALUES (1, NULL), (1, 2), (1, 3), (2, 10), (2, 0)) AS t2(k, t)
4545
MATCH_CONDITION t2.t < t1.t
46-
ON t1.k = t2.k
47-
;
46+
ON t1.k = t2.k;
4847
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
4948
LogicalProject(K=[$0], T=[$1], K0=[$2], T0=[$3])
5049
LogicalAsofJoin(condition=[=($0, $2)], joinType=[asof], matchCondition=[<($3, $1)])
@@ -84,9 +83,9 @@ LogicalProject(T=[CASE(<(CAST(CASE(>($1, 'abc'), $1, null:VARCHAR(20))):DOUBLE,
8483
# function has already been expanded (checkUnchanged).
8584

8685
select COUNT(*) over (
87-
ORDER BY empno
88-
ROWS BETWEEN 5 + 5 PRECEDING AND 1 PRECEDING) AS w_count from emp
89-
;
86+
ORDER BY empno
87+
ROWS BETWEEN 5 + 5 PRECEDING AND 1 PRECEDING) AS w_count
88+
from emp;
9089
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
9190
LogicalProject(W_COUNT=[$1])
9291
LogicalWindow(window#0=[window(order by [0] rows between $1 PRECEDING and $2 PRECEDING aggs [COUNT()])], constants=[[10, 1]])
@@ -283,33 +282,6 @@ LogicalProject(EXPR$0=[1], A=[$1])
283282
LogicalValues(tuples=[[{ 0 }]])
284283
!sub-plan "NONE, PROJECT_REDUCE_EXPRESSIONS"
285284

286-
# testReduceCastAndConsts -------------------------------------------------------
287-
# Tests that constant expressions inside a cast can be reduced.
288-
289-
select * from emp
290-
where cast((empno + (10/2)) as int) = 13;
291-
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
292-
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
293-
LogicalFilter(condition=[=(CAST(+($0, /(10, 2))):INTEGER NOT NULL, 13)])
294-
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
295-
!sub-plan "NONE"
296-
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
297-
LogicalFilter(condition=[=(+($0, 5), 13)])
298-
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
299-
!sub-plan "NONE, FILTER_REDUCE_EXPRESSIONS"
300-
301-
# testReduceCastTimeUnchanged -------------------------------------------------------
302-
# Tests that a cast from a TIME to a TIMESTAMP is not reduced (depends on current date).
303-
304-
select cast(time '12:34:56' as timestamp) from emp as e;
305-
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
306-
LogicalProject(EXPR$0=[CAST(12:34:56):TIMESTAMP(0) NOT NULL])
307-
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
308-
!sub-plan "NONE"
309-
LogicalProject(EXPR$0=[CAST(12:34:56):TIMESTAMP(0) NOT NULL])
310-
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
311-
!sub-plan "NONE, PROJECT_REDUCE_EXPRESSIONS, FILTER_REDUCE_EXPRESSIONS, JOIN_REDUCE_EXPRESSIONS"
312-
313285
# testReduceCase -------------------------------------------------------
314286
# PROJECT_REDUCE_EXPRESSIONS reduces a CASE expression with a false condition
315287
# to the else branch, unifying numeric types.
@@ -342,6 +314,21 @@ LogicalProject(QX=[CAST(CASE(=($0, 1), 1, 2)):INTEGER])
342314
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
343315
!sub-plan "relBuilderSimplify=false, NONE, FILTER_REDUCE_EXPRESSIONS, PROJECT_REDUCE_EXPRESSIONS"
344316

317+
# testReduceCastAndConsts -------------------------------------------------------
318+
# Tests that constant expressions inside a cast can be reduced.
319+
320+
select * from emp
321+
where cast((empno + (10/2)) as int) = 13;
322+
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
323+
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
324+
LogicalFilter(condition=[=(CAST(+($0, /(10, 2))):INTEGER NOT NULL, 13)])
325+
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
326+
!sub-plan "NONE"
327+
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
328+
LogicalFilter(condition=[=(+($0, 5), 13)])
329+
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
330+
!sub-plan "NONE, FILTER_REDUCE_EXPRESSIONS"
331+
345332
# testReduceCasts -------------------------------------------------------
346333
# PROJECT_REDUCE_EXPRESSIONS, JOIN_REDUCE_EXPRESSIONS, and FILTER_REDUCE_EXPRESSIONS
347334
# remove redundant casts (e.g., CAST(integer AS integer) becomes the column itself).
@@ -371,6 +358,18 @@ LogicalProject(EXPR$0=[CAST($1):VARCHAR(128) NOT NULL], EXPR$1=[$2])
371358
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
372359
!sub-plan "relBuilderSimplify=false, NONE, PROJECT_REDUCE_EXPRESSIONS, FILTER_REDUCE_EXPRESSIONS, JOIN_REDUCE_EXPRESSIONS"
373360

361+
# testReduceCastTimeUnchanged -------------------------------------------------------
362+
# Tests that a cast from a TIME to a TIMESTAMP is not reduced (depends on current date).
363+
364+
select cast(time '12:34:56' as timestamp) from emp as e;
365+
# Not using !ok: this test focuses on plan transformation (see !sub-plan).
366+
LogicalProject(EXPR$0=[CAST(12:34:56):TIMESTAMP(0) NOT NULL])
367+
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
368+
!sub-plan "NONE"
369+
LogicalProject(EXPR$0=[CAST(12:34:56):TIMESTAMP(0) NOT NULL])
370+
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
371+
!sub-plan "NONE, PROJECT_REDUCE_EXPRESSIONS, FILTER_REDUCE_EXPRESSIONS, JOIN_REDUCE_EXPRESSIONS"
372+
374373
# testReduceCompositeInSubQuery -------------------------------------------------------
375374
# [CALCITE-6887] FILTER_REDUCE_EXPRESSIONS reduces a constant expression in an
376375
# OR condition that contains a composite IN subquery.

0 commit comments

Comments
 (0)