YiwenWu commented on code in PR #3817: URL: https://github.com/apache/calcite/pull/3817#discussion_r1639114996
########## 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(<result>) + * ELSE (SELECT NULL UNION ALL SELECT NULL)) Review Comment: 1. A problem: `SELECT NULL UNION ALL SELECT NULL` will return two NULL values instead of one. 2. Suggestion: Use `COUNT(field)` instead of `COUNT(*)` -- 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