@@ -42,4 +42,58 @@ SELECT * FROM t0 WHERE t0a <
4242
4343!ok
4444
45+ # [CALCITE-7356] The MARK JOIN generated by TopDownGeneralDecorrelator needs to be adapted to RelFieldTrimmer
46+ !use blank
47+ CREATE TABLE emps (
48+ empid INTEGER NOT NULL,
49+ deptno INTEGER NOT NULL,
50+ name VARCHAR(10) NOT NULL,
51+ salary DECIMAL(10, 2) NOT NULL,
52+ commission INTEGER);
53+ (0 rows modified)
54+
55+ !update
56+
57+ INSERT INTO emps (empid, deptno, name, salary, commission) VALUES
58+ (100, 10, 'Bill', 10000.00, 1000),
59+ (200, 20, 'Eric', 8000.00, 500),
60+ (150, 10, 'Sebastian', 7000.00, NULL),
61+ (110, 10, 'Theodore', 11500.00, 250),
62+ (170, 30, 'Theodore', 11500.00, 250),
63+ (140, 10, 'Sebastian', 7000.00, NULL);
64+ (6 rows modified)
65+
66+ !update
67+
68+ SELECT *, EXISTS(select * from (
69+ SELECT e2.deptno FROM emps e2 where e1.commission = e2.commission) as table3
70+ where table3.deptno <> e1.deptno)
71+ from emps e1 order by empid;
72+ +-------+--------+-----------+----------+------------+--------+
73+ | EMPID | DEPTNO | NAME | SALARY | COMMISSION | EXPR$5 |
74+ +-------+--------+-----------+----------+------------+--------+
75+ | 100 | 10 | Bill | 10000.00 | 1000 | false |
76+ | 110 | 10 | Theodore | 11500.00 | 250 | true |
77+ | 140 | 10 | Sebastian | 7000.00 | | false |
78+ | 150 | 10 | Sebastian | 7000.00 | | false |
79+ | 170 | 30 | Theodore | 11500.00 | 250 | true |
80+ | 200 | 20 | Eric | 8000.00 | 500 | false |
81+ +-------+--------+-----------+----------+------------+--------+
82+ (6 rows)
83+
84+ !ok
85+
86+ !if (use_new_decorr) {
87+ EnumerableSort(sort0=[$0], dir0=[ASC])
88+ EnumerableHashJoin(condition=[AND(IS NOT DISTINCT FROM($1, $6), IS NOT DISTINCT FROM($4, $7))], joinType=[left_mark])
89+ EnumerableTableScan(table=[[BLANK, EMPS]])
90+ EnumerableCalc(expr#0..3=[{inputs}], DEPTNO=[$t2], DEPTNO0=[$t0], COMMISSION0=[$t1])
91+ EnumerableHashJoin(condition=[AND(=($1, $3), <>($2, $0))], joinType=[inner])
92+ EnumerableAggregate(group=[{1, 4}])
93+ EnumerableTableScan(table=[[BLANK, EMPS]])
94+ EnumerableCalc(expr#0..4=[{inputs}], DEPTNO=[$t1], COMMISSION=[$t4])
95+ EnumerableTableScan(table=[[BLANK, EMPS]])
96+ !plan
97+ !}
98+
4599# End new-decorr.iq
0 commit comments