NobiGo commented on code in PR #4419:
URL: https://github.com/apache/calcite/pull/4419#discussion_r2149701391


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -783,17 +783,23 @@ public SqlNode toSql(@Nullable RexProgram program, 
RexNode rex) {
       case IN:
       case SOME:
       case ALL:
-        subQuery = (RexSubQuery) rex;
-        sqlSubQuery = implementor().visitRoot(subQuery.rel).asQueryOrValues();
-        final List<RexNode> operands = subQuery.operands;
-        SqlNode op0;
-        if (operands.size() == 1) {
-          op0 = toSql(program, operands.get(0));
-        } else {
-          final List<SqlNode> cols = toSql(program, operands);
-          op0 = new SqlNodeList(cols, POS);
+        if (rex instanceof RexSubQuery) {
+          subQuery = (RexSubQuery) rex;
+          sqlSubQuery = 
implementor().visitRoot(subQuery.rel).asQueryOrValues();
+          final List<RexNode> operands = subQuery.operands;
+          SqlNode op0;
+          if (operands.size() == 1) {
+            op0 = toSql(program, operands.get(0));
+          } else {
+            final List<SqlNode> cols = toSql(program, operands);
+            op0 = new SqlNodeList(cols, POS);
+          }
+          return subQuery.getOperator().createCall(POS, op0, sqlSubQuery);
         }
-        return subQuery.getOperator().createCall(POS, op0, sqlSubQuery);
+        if (rex instanceof RexOver) {

Review Comment:
   Is there any unit test involved in this logic?



##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2515,6 +2515,47 @@ private SqlDialect nonOrdinalDialect() {
         .withPostgresql().ok(expectedPostgresql);
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-7056";>[CALCITE-7056]
+   * Convert RelNode to Sql failed when the RelNode includes quantify 
operators</a>.
+   */
+  @Test void testQuantifyOperatorsWithTypeCoercion() {
+    final String query = "SELECT timestamp '1970-01-01 01:23:45'"

Review Comment:
   What would be the output if the input SQL is the same as that described in 
Jira?



-- 
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]

Reply via email to