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_r397182890
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java
 ##########
 @@ -557,6 +557,55 @@ 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);
+    // passing random value for scale2
+    // since the default behaviour is to have the return type of result as the 
first operand
+    return typeFactory.getTypeSystem().deriveDecimalTruncateType(typeFactory, 
type1, 0);
+  };
 
 Review comment:
   This enables to override the behaviour if needed.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to