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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -2216,7 +2216,39 @@ private static RelDataType 
deriveTypeMapFromEntries(SqlOperatorBinding opBinding
 
   @LibraryOperator(libraries = {BIG_QUERY, SPARK})
   public static final SqlFunction POW =
-      SqlStdOperatorTable.POWER.withName("POW");
+      SqlBasicFunction.create("POW",
+          ReturnTypes.DOUBLE_NULLABLE,
+          OperandTypes.NUMERIC_NUMERIC,
+          SqlFunctionCategory.NUMERIC);
+
+  /** The {@code POWER(numeric, numeric)} function.
+   *
+   * <p>The return type is always {@code DOUBLE} since we don't know
+   * what the result type will be by just looking at the operand types. For
+   * example {@code POWER(INTEGER, INTEGER)} can return a non-INTEGER if the
+   * second operand is negative.
+   */
+  @LibraryOperator(libraries = { BIG_QUERY, CALCITE, HIVE, MSSQL, MYSQL, 
ORACLE, SNOWFLAKE,
+      SPARK })
+  public static final SqlFunction POWER =
+      SqlBasicFunction.create("POWER",
+          ReturnTypes.DOUBLE_NULLABLE,
+          OperandTypes.NUMERIC_NUMERIC,
+          SqlFunctionCategory.NUMERIC);
+
+  /** The {@code POWER(numeric, numeric)} function.
+   *
+   * <p>The return type is always {@code DOUBLE} since we don't know

Review Comment:
   this comment seems wrong



##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -559,15 +558,6 @@ static SqlOperatorTable operatorTableFor(SqlLibrary 
library) {
   }
 
   @Test void testArithmeticOperatorsFails() {
-    expr("^power(2,'abc')^")

Review Comment:
   why delete these tests? What happens to them? They look like good tests.



##########
testkit/src/main/java/org/apache/calcite/sql/parser/SqlParserTest.java:
##########
@@ -2006,7 +2006,7 @@ void checkPeriodPredicate(Checker checker) {
     expr("1-2+3*4/5/6-7")
         .ok("(((1 - 2) + (((3 * 4) / 5) / 6)) - 7)");
     expr("power(2,3)")
-        .ok("POWER(2, 3)");
+        .ok("`POWER`(2, 3)");

Review Comment:
   these quotes look suspicious



##########
core/src/test/resources/sql/misc.iq:
##########
@@ -2301,17 +2301,6 @@ where false;
 
 !ok
 
-# [CALCITE-2447] POWER, ATAN2 functions fail with NoSuchMethodException

Review Comment:
   why delete this test?



##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -773,6 +791,28 @@ public static SqlCall stripSeparator(SqlCall call) {
     return null;
   };
 
+  public static final SqlReturnTypeInference DECIMAL_OR_DOUBLE = opBinding -> {

Review Comment:
   why have both DOUBLE_OR_DECIMAL and DECIMAL_OR_DOUBLE?



##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -410,6 +410,24 @@ public static SqlCall stripSeparator(SqlCall call) {
   public static final SqlReturnTypeInference DOUBLE_FORCE_NULLABLE =
       DOUBLE.andThen(SqlTypeTransforms.FORCE_NULLABLE);
 
+  /**

Review Comment:
   this comment seems wrong too



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