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


##########
core/src/main/java/org/apache/calcite/sql/dialect/SparkSqlDialect.java:
##########
@@ -152,4 +159,39 @@ public SparkSqlDialect(SqlDialect.Context context) {
     }
     return super.getCastSpec(type);
   }
+
+  /**
+   * Rewrite SINGLE_VALUE.
+   *
+   * <pre>In Spark, RAISE_ERROR("more than one value in agg SINGLE_VALUE")
+   * will throw exception.</pre>
+   *
+   * <blockquote><pre>
+   * CASE COUNT(*)
+   * WHEN 0 THEN NULL
+   * WHEN 1 THEN MIN(&lt;result&gt;)
+   * ELSE RAISE_ERROR("more than one value in agg SINGLE_VALUE")
+   * </pre></blockquote>
+   */
+  @Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall, RelDataType 
relDataType) {
+    final SqlNode operand = ((SqlBasicCall) aggCall).operand(0);

Review Comment:
   The current conversion here is consistent with other dialect conversions, so 
no adjustments have been made.



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