diff --git a/omnioperator/omniop-spark-extension/java/src/main/scala/com/huawei/boostkit/spark/expression/OmniExpressionAdaptor.scala b/omnioperator/omniop-spark-extension/java/src/main/scala/com/huawei/boostkit/spark/expression/OmniExpressionAdaptor.scala index c760d6ee5f39314d7f4903314af7ef9910b1c5a3..853462e3c6fef2b2653950253c09e229537f09ae 100644 --- a/omnioperator/omniop-spark-extension/java/src/main/scala/com/huawei/boostkit/spark/expression/OmniExpressionAdaptor.scala +++ b/omnioperator/omniop-spark-extension/java/src/main/scala/com/huawei/boostkit/spark/expression/OmniExpressionAdaptor.scala @@ -328,22 +328,18 @@ object OmniExpressionAdaptor extends Logging { expr match { case unscaledValue: UnscaledValue => ("{\"exprType\":\"FUNCTION\",\"returnType\":%s," + - "\"function_name\":\"UnscaledValue\", \"arguments\":[%s, %s, %s]}") + "\"function_name\":\"UnscaledValue\", \"arguments\":[%s]}") .format(sparkTypeToOmniExpJsonType(unscaledValue.dataType), - rewriteToOmniJsonExpressionLiteral(unscaledValue.child, exprsIndexMap), - toOmniJsonLiteral( - Literal(unscaledValue.child.dataType.asInstanceOf[DecimalType].precision, IntegerType)), - toOmniJsonLiteral( - Literal(unscaledValue.child.dataType.asInstanceOf[DecimalType].scale, IntegerType))) + rewriteToOmniJsonExpressionLiteral(unscaledValue.child, exprsIndexMap)) // omni not support return null, now rewrite to if(IsOverflowDecimal())? NULL:MakeDecimal() case checkOverflow: CheckOverflow => ("{\"exprType\":\"IF\",\"returnType\":%s," + "\"condition\":{\"exprType\":\"FUNCTION\",\"returnType\":%s," + - "\"function_name\":\"IsOverflowDecimal\",\"arguments\":[%s,%s,%s,%s,%s]}," + + "\"function_name\":\"IsOverflowDecimal\",\"arguments\":[%s,%s,%s]}," + "\"if_true\":%s," + "\"if_false\":{\"exprType\":\"FUNCTION\",\"returnType\":%s," + - "\"function_name\":\"MakeDecimal\", \"arguments\":[%s,%s,%s,%s,%s]}" + + "\"function_name\":\"MakeDecimal\", \"arguments\":[%s]}" + "}") .format(sparkTypeToOmniExpJsonType(checkOverflow.dataType), // IsOverflowDecimal returnType @@ -355,10 +351,6 @@ object OmniExpressionAdaptor extends Logging { Literal(checkOverflow.dataType.precision, IntegerType)), toOmniJsonLiteral( Literal(checkOverflow.dataType.scale, IntegerType)), - toOmniJsonLiteral( - Literal(checkOverflow.dataType.precision, IntegerType)), - toOmniJsonLiteral( - Literal(checkOverflow.dataType.scale, IntegerType)), // if_true toOmniJsonLiteral( Literal(null, checkOverflow.dataType)), @@ -367,41 +359,21 @@ object OmniExpressionAdaptor extends Logging { DecimalType(checkOverflow.dataType.precision, checkOverflow.dataType.scale)), rewriteToOmniJsonExpressionLiteral(checkOverflow.child, exprsIndexMap, - DecimalType(checkOverflow.dataType.precision, checkOverflow.dataType.scale)), - toOmniJsonLiteral( - Literal(checkOverflow.dataType.precision, IntegerType)), - toOmniJsonLiteral( - Literal(checkOverflow.dataType.scale, IntegerType)), - toOmniJsonLiteral( - Literal(checkOverflow.dataType.precision, IntegerType)), - toOmniJsonLiteral( - Literal(checkOverflow.dataType.scale, IntegerType))) + DecimalType(checkOverflow.dataType.precision, checkOverflow.dataType.scale))) case makeDecimal: MakeDecimal => makeDecimal.child.dataType match { case decimalChild: DecimalType => ("{\"exprType\": \"FUNCTION\", \"returnType\":%s," + - "\"function_name\": \"MakeDecimal\", \"arguments\": [%s,%s,%s,%s,%s]}") + "\"function_name\": \"MakeDecimal\", \"arguments\": [%s]}") .format(sparkTypeToOmniExpJsonType(makeDecimal.dataType), - rewriteToOmniJsonExpressionLiteral(makeDecimal.child, exprsIndexMap), - toOmniJsonLiteral( - Literal(decimalChild.precision, IntegerType)), - toOmniJsonLiteral( - Literal(decimalChild.scale, IntegerType)), - toOmniJsonLiteral( - Literal(makeDecimal.precision, IntegerType)), - toOmniJsonLiteral( - Literal(makeDecimal.scale, IntegerType))) + rewriteToOmniJsonExpressionLiteral(makeDecimal.child, exprsIndexMap)) case longChild: LongType => ("{\"exprType\": \"FUNCTION\", \"returnType\":%s," + - "\"function_name\": \"MakeDecimal\", \"arguments\": [%s,%s,%s]}") + "\"function_name\": \"MakeDecimal\", \"arguments\": [%s]}") .format(sparkTypeToOmniExpJsonType(makeDecimal.dataType), - rewriteToOmniJsonExpressionLiteral(makeDecimal.child, exprsIndexMap), - toOmniJsonLiteral( - Literal(makeDecimal.precision, IntegerType)), - toOmniJsonLiteral( - Literal(makeDecimal.scale, IntegerType))) + rewriteToOmniJsonExpressionLiteral(makeDecimal.child, exprsIndexMap)) case _ => throw new UnsupportedOperationException(s"Unsupported datatype for MakeDecimal: ${makeDecimal.child.dataType}") } @@ -530,10 +502,8 @@ object OmniExpressionAdaptor extends Logging { case dt: DecimalType => if (cast.child.dataType.isInstanceOf[DoubleType]) { ("{\"exprType\":\"FUNCTION\",\"returnType\":%s," + - "\"function_name\":\"CAST\", \"arguments\":[%s,%s,%s]}") - .format(returnType, rewriteToOmniJsonExpressionLiteral(cast.child, exprsIndexMap), - toOmniJsonLiteral(Literal(dt.precision, IntegerType)), - toOmniJsonLiteral(Literal(dt.scale, IntegerType))) + "\"function_name\":\"CAST\", \"arguments\":[%s]}") + .format(returnType, rewriteToOmniJsonExpressionLiteral(cast.child, exprsIndexMap)) } else { rewriteToOmniJsonExpressionLiteral( MakeDecimal(cast.child, dt.precision, dt.scale), exprsIndexMap)