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_r303748726
##########
File path: core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java
##########
@@ -563,6 +538,23 @@ public int size() {
public static final SqlReturnTypeInference NULLABLE_SUM =
new SqlReturnTypeInferenceChain(DECIMAL_SUM_NULLABLE, LEAST_RESTRICTIVE);
+ public static final SqlReturnTypeInference DECIMAL_MOD = opBinding -> {
+ RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
+ RelDataType type1 = opBinding.getOperandType(0);
+ RelDataType type2 = opBinding.getOperandType(1);
+ return typeFactory.getTypeSystem().deriveDecimalModType(typeFactory,
type1, type2);
+ };
+
+ private static final SqlReturnTypeInference DECIMAL_MOD_NULLABLE =
+ cascade(DECIMAL_MOD, SqlTypeTransforms.TO_NULLABLE);
+ /**
+ * Type-inference strategy whereby the result type of a call is
+ * {@link #DECIMAL_SUM_NULLABLE} with a fallback to {@link
#LEAST_RESTRICTIVE}
+ * These rules are used for addition and subtraction.
Review comment:
for modulo
----------------------------------------------------------------
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