dawidwys commented on a change in pull request #12464:
URL: https://github.com/apache/flink/pull/12464#discussion_r436643472



##########
File path: 
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java
##########
@@ -430,54 +440,128 @@
                        .build();
 
        // math functions
+
+       /**
+        * Combines numeric addition, "datetime + interval"/"interval + 
interval" arithmetic, and string concatenation.
+        */
        public static final BuiltInFunctionDefinition PLUS =
                new BuiltInFunctionDefinition.Builder()
                        .name("plus")
                        .kind(SCALAR)
-                       .outputTypeStrategy(TypeStrategies.MISSING)
+                       .inputTypeStrategy(
+                               or(
+                                       
sequence(logical(LogicalTypeFamily.NUMERIC), 
logical(LogicalTypeFamily.NUMERIC)),
+                                       
sequence(logical(LogicalTypeRoot.INTERVAL_DAY_TIME), 
logical(LogicalTypeRoot.INTERVAL_DAY_TIME)),
+                                       
sequence(logical(LogicalTypeRoot.INTERVAL_YEAR_MONTH), 
logical(LogicalTypeRoot.INTERVAL_YEAR_MONTH)),
+                                       
sequence(logical(LogicalTypeFamily.DATETIME), 
logical(LogicalTypeFamily.INTERVAL)),
+                                       
sequence(logical(LogicalTypeFamily.INTERVAL), 
logical(LogicalTypeFamily.DATETIME)),
+                                       
sequence(logical(LogicalTypeFamily.CHARACTER_STRING), 
logical(LogicalTypeFamily.PREDEFINED))))
+                       .outputTypeStrategy(
+                               nullable(
+                                       first(
+                                               DECIMAL_SUM,

Review comment:
       Shall we call it `DECIMAL_PLUS`?
   
   There is also `SUM` aggregate function which has a different rule.

##########
File path: 
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeMerging.java
##########
@@ -193,6 +193,56 @@ private static void addDayTimeMapping(DayTimeResolution 
to, DayTimeResolution...
                return Optional.empty();
        }
 
+       /**
+        * Finds the result type of a decimal division operation.
+        */
+       public static DecimalType findDivisionDecimalType(int precision1, int 
scale1, int precision2, int scale2) {
+               // adopted from 
https://docs.microsoft.com/en-us/sql/t-sql/data-types/precision-scale-and-length-transact-sql

Review comment:
       I am not sure if we want to point to a different source here. As far as 
I can tell it is also the same logic that Calcite applies.
   
   Otherwise there might be questions why don't we use the SQL Server algorithm 
for `+/-`.




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


Reply via email to