xiedeyantu commented on PR #4209:
URL: https://github.com/apache/calcite/pull/4209#issuecomment-2688337810
> ```
> @Test void testIntersect() {
> final String sql = ""
> + "select \"empid\", \"name\" from \"hr\".\"emps\" where
\"deptno\"=10\n"
> + "intersect\n"
> + "select \"empid\", \"name\" from \"hr\".\"emps\" where
\"empid\">=150";
> CalciteAssert.hr()
> .query(sql)
> .withHook(Hook.PLANNER, (Consumer<RelOptPlanner>)
> planner -> {
> planner.removeRule(CoreRules.INTERSECT_TO_DISTINCT);
> planner.removeRule(EnumerableRules.ENUMERABLE_INTERSECT_RULE);
> planner.addRule(CoreRules.INTERSECT_TO_EXISTS);
> })
> .explainContains("")
> .returnsUnordered("empid=150; name=Sebastian");
> }
> ```
>
> You can try this unit test in JdbcTest. Now it throws exception.
@NobiGo I have debugged the code and modified some of the logic, but there
are still errors. as
```
cannot translate expression EXISTS({
LogicalFilter(condition=[AND(IS NOT DISTINCT FROM($0, $cor0.empid), IS NOT
DISTINCT FROM($1, $cor0.name))])
LogicalFilter(subset=[rel#282:RelSubset#5.NONE.[]], condition=[>=($0,
150)])
LogicalProject(subset=[rel#280:RelSubset#4.NONE.[]], empid=[$0],
name=[$2])
LogicalTableScan(subset=[rel#272:RelSubset#0.NONE.[]], table=[[hr,
emps]])
})
```
the stack is
```
0 = {StackTraceElement@7965}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitSubQuery(RexToLixTranslator.java:1701)"
1 = {StackTraceElement@7966}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitSubQuery(RexToLixTranslator.java:108)"
2 = {StackTraceElement@7967}
"org.apache.calcite.rex.RexSubQuery.accept(RexSubQuery.java:162)"
3 = {StackTraceElement@7968}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.implementCallOperand(RexToLixTranslator.java:1439)"
4 = {StackTraceElement@7969}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:1426)"
5 = {StackTraceElement@7970}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:108)"
6 = {StackTraceElement@7971}
"org.apache.calcite.rex.RexCall.accept(RexCall.java:208)"
7 = {StackTraceElement@7972}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:1306)"
8 = {StackTraceElement@7973}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:108)"
9 = {StackTraceElement@7974}
"org.apache.calcite.rex.RexLocalRef.accept(RexLocalRef.java:78)"
10 = {StackTraceElement@7975}
"org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:260)"
```
it seems not support exectue subquery, as I mentioned before. Are there any
other solutions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]