Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1634#discussion_r52921997
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/codegen/OperatorCodeGen.scala
---
@@ -18,20 +18,56 @@
package org.apache.flink.api.table.codegen
import org.apache.flink.api.common.typeinfo.BasicTypeInfo.BOOLEAN_TYPE_INFO
-import org.apache.flink.api.common.typeinfo.TypeInformation
+import org.apache.flink.api.common.typeinfo.{NumericTypeInfo,
TypeInformation}
import org.apache.flink.api.table.codegen.CodeGenUtils._
object OperatorCodeGen {
- def generateArithmeticOperator(
+ def generateArithmeticOperator(
operator: String,
nullCheck: Boolean,
resultType: TypeInformation[_],
left: GeneratedExpression,
right: GeneratedExpression)
: GeneratedExpression = {
- generateOperatorIfNotNull(nullCheck, resultType, left, right) {
+ // String arithmetic // TODO rework
+ if (isString(left)) {
+ generateOperatorIfNotNull(nullCheck, resultType, left, right) {
(leftTerm, rightTerm) => s"$leftTerm $operator $rightTerm"
+ }
+ }
+ // Numeric arithmetic
+ else if (isNumeric(left) && isNumeric(right)) {
+ val leftType = left.resultType.asInstanceOf[NumericTypeInfo[_]]
+ val rightType = right.resultType.asInstanceOf[NumericTypeInfo[_]]
+
+ generateOperatorIfNotNull(nullCheck, resultType, left, right) {
+ (leftTerm, rightTerm) =>
+ // insert auto casting for "narrowing primitive conversions"
+ if (leftType != rightType) {
--- End diff --
Shouldn't we compare and cast to the result type?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---