laurentgo commented on a change in pull request #1311: CALCITE-3187: Make 
decimal type inference overridable.
URL: https://github.com/apache/calcite/pull/1311#discussion_r301870083
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java
 ##########
 @@ -515,38 +515,17 @@ public int size() {
    *
    * @see Glossary#SQL2003 SQL:2003 Part 2 Section 6.26
    */
-  public static final SqlReturnTypeInference DECIMAL_SUM = opBinding -> {
-    RelDataType type1 = opBinding.getOperandType(0);
-    RelDataType type2 = opBinding.getOperandType(1);
-    if (SqlTypeUtil.isExactNumeric(type1)
-        && SqlTypeUtil.isExactNumeric(type2)) {
-      if (SqlTypeUtil.isDecimal(type1)
-          || SqlTypeUtil.isDecimal(type2)) {
-        int p1 = type1.getPrecision();
-        int p2 = type2.getPrecision();
-        int s1 = type1.getScale();
-        int s2 = type2.getScale();
-
-        final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
-        int scale = Math.max(s1, s2);
-        final RelDataTypeSystem typeSystem = typeFactory.getTypeSystem();
-        assert scale <= typeSystem.getMaxNumericScale();
-        int precision = Math.max(p1 - s1, p2 - s2) + scale + 1;
-        precision =
-            Math.min(
-                precision,
-                typeSystem.getMaxNumericPrecision());
-        assert precision > 0;
-
-        return typeFactory.createSqlType(
-            SqlTypeName.DECIMAL,
-            precision,
-            scale);
-      }
-    }
+  public static final SqlReturnTypeInference DECIMAL_SUM =
 
 Review comment:
   Please preserve the style and use lambda

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