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


##########
core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java:
##########
@@ -166,4 +173,36 @@ public HiveSqlDialect(Context context) {
     }
     return super.getCastSpec(type);
   }
+
+  /**
+   * Rewrite SINGLE_VALUE.

Review Comment:
   SINGLE_VALUE(result)



##########
core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java:
##########
@@ -166,4 +173,36 @@ public HiveSqlDialect(Context context) {
     }
     return super.getCastSpec(type);
   }
+
+  /**
+   * Rewrite SINGLE_VALUE.
+   *
+   * <pre>In Hive, ASSERT_TRUE(false) will throw assertion failed 
exception.</pre>

Review Comment:
   I would swap this <pre> with the next one.
   It makes it look like you are solving a problem related to ASSERT_TRUE.



##########
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:
   I don't know if you care to preserve the position of the aggCall in the 
constructed tree.



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