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


##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
               timeUnitNode.getParserPosition());
       SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", 
false);
       break;
+    case IS_TRUE:
+      if (this.supportMacroLikeUnparse()) {

Review Comment:
   BTW: I have the impression that there are other places in Calcite where 
expressions are copied without concern for deterministic behavior.



##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
               timeUnitNode.getParserPosition());
       SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", 
false);
       break;
+    case IS_TRUE:
+      if (this.supportMacroLikeUnparse()) {

Review Comment:
   how about having a conservative approximation?
   for example, you can have a shuttle which checks whether operand(0) invokes 
a non-deterministic function.
   You can approximate that by "calls any function" for now.
   Or the dialect could have a list of non-deterministic function names, there 
aren't that many.



##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -795,6 +795,14 @@ public boolean supportBooleanCaseWhen() {
     return true;
   }
 
+  /**
+   * Returns whether to enable unparse of "macro-like" calls such as IS TRUE.
+   * "A IS TRUE" can be unparse to "A IS NOT NULL AND A" When A is 
deterministic.
+   * Otherwise, inconsistent results may occur. */
+  public boolean supportMacroLikeUnparse() {

Review Comment:
   I don't understand how this fixes the problem of non-deterministic functions.



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