wangdiao commented on code in PR #4224:
URL: https://github.com/apache/calcite/pull/4224#discussion_r1984347557
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlQuantifyOperator.java:
##########
@@ -118,4 +119,42 @@ public class SqlQuantifyOperator extends SqlInOperator {
}
return null;
}
+
+ @Override public SqlOperator not() {
Review Comment:
When `<All` convertTo `NOT(>= SOME)`, it is used for toSql.
e.g.
The test on `RelToSqlConverterTest#testAll` this commit
SQL: `SELECT 1, "gross_weight" < ALL(SELECT "gross_weight" FROM
"foodmart"."product") AS "t" FROM "foodmart"."product"`
Converted rel:
```
rel#10:LogicalProject.NONE.[](input=JdbcTableScan#7,exprs=[1, NOT(>=
SOME($6, {
LogicalProject(gross_weight=[$6])
JdbcTableScan(table=[[foodmart, product]])
}))])
```
ToSql:
call `SqlImplementor.Context#toSql(RexProgram,RexNode):`
```
case NOT:
RexNode operand = ((RexCall) rex).operands.get(0);
final SqlNode node = toSql(program, operand);
final SqlOperator inverseOperator = getInverseOperator(operand);
//line 802
```
`getInverseOperator` use the function `not`.
If not done, it will throw unexpected SOME.
```
java.lang.AssertionError: unexpected SOME
at org.apache.calcite.sql.fun.SqlInOperator.of(SqlInOperator.java:98)
at org.apache.calcite.sql.fun.SqlInOperator.not(SqlInOperator.java:84)
at
org.apache.calcite.rel.rel2sql.SqlImplementor$Context.getInverseOperator(SqlImplementor.java:914)
at
org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:802)
at
org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:460)
```
--
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]