anilbash commented on a change in pull request #1859: [CALCITE-3863] Make 
Truncate/Round return type inference overridable through rel data …
URL: https://github.com/apache/calcite/pull/1859#discussion_r394286883
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java
 ##########
 @@ -557,6 +557,32 @@ public int size() {
   public static final SqlReturnTypeInference NULLABLE_MOD =
           chain(DECIMAL_MOD_NULLABLE, ARG1_NULLABLE);
 
+  public static final SqlReturnTypeInference DECIMAL_TRUNCATE = opBinding -> {
+    RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
+    RelDataType type1 = opBinding.getOperandType(0);
+    Integer scale = 0;
+    if (opBinding.getOperandCount() > 1) {
+      scale = opBinding.getOperandLiteralValue(1, Integer.class);
+    }
+    return typeFactory.getTypeSystem().deriveDecimalTruncateType(typeFactory, 
type1, scale);
+  };
+
+  /**
+   * Type-inference strategy whereby the result type of a call is the decimal
+   * truncate of two exact numeric operands where at least one of the operands 
is a
+   * decimal.
+   */
+  public static final SqlReturnTypeInference DECIMAL_TRUNCATE_NULLABLE =
+      cascade(DECIMAL_TRUNCATE, SqlTypeTransforms.TO_NULLABLE);
+
+  /**
+   * Type-inference strategy whereby the result type of a call is
 
 Review comment:
   Added test cases.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to