YiwenWu commented on code in PR #3817:
URL: https://github.com/apache/calcite/pull/3817#discussion_r1642057291


##########
core/src/main/java/org/apache/calcite/util/RelToSqlConverterUtil.java:
##########
@@ -93,6 +101,41 @@ public static void unparseSparkArrayAndMap(SqlWriter writer,
     writer.endList(frame);
   }
 
+
+  /**
+   * Rewrite SINGLE_VALUE use SparkSQL Mode.
+   *
+   * <blockquote><pre>
+   * CASE COUNT(*)
+   * WHEN 0 THEN NULL
+   * WHEN 1 THEN MIN(&lt;result&gt;)
+   * ELSE (SELECT NULL UNION ALL SELECT NULL))

Review Comment:
   > > 1. SELECT NULL UNION ALL SELECT NULL
   > 
   > this is intentional to make sure when the subquery include more then one 
value ,This SQL will throw exception.
   > 
   > 2: Suggestion: Use COUNT(field) instead of COUNT(*)
   > 
   > Please check 
[CALCITE-6430](https://issues.apache.org/jira/browse/CALCITE-6430).
   
   got it, thanks. Based on count(*) and union all, the result of the subquery 
is guaranteed to be only one row.



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to