mihaibudiu commented on code in PR #4402:
URL: https://github.com/apache/calcite/pull/4402#discussion_r2136369319
##########
core/src/main/java/org/apache/calcite/sql/SqlOperator.java:
##########
@@ -1036,6 +1036,19 @@ public <R> void acceptCall(
return null;
}
+ /**
+ * Returns whether this is a safe operator that doesn't throw any exception.
+ *
+ * <p> If an operator is a safe operator, we will check its parameters to
determine
+ * if the entire expression is safe.
+ *
+ * <p>For example, {@code 1/0 + null} is not safe. Because even though the
+ * {@code SqlStdOperatorTable.PLUS} is safe operator but its operands is not
safe.
+ */
+ public Boolean isSafeOperator() {
Review Comment:
Another subtle point is that the safety is a function of the SQL dialect.
For example, in sqlite division by 0 returns NULL.
In some dialects arithmetic is checked (so overflow is unsafe), while in
other dialects arithmetic is wrap-around. In Calcite this is controlled by
SqlConformance.checkedArithmetic().
In general, this "safe" annotation would have to be the most conservative
possible - i.e., it works for any possible dialect.
--
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]