Yohahaha commented on code in PR #5789:
URL: https://github.com/apache/incubator-gluten/pull/5789#discussion_r1606184878
##########
backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxSparkPlanExecApi.scala:
##########
@@ -61,61 +59,21 @@ import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types._
import org.apache.spark.sql.vectorized.ColumnarBatch
-import com.google.common.collect.Lists
import org.apache.commons.lang3.ClassUtils
import javax.ws.rs.core.UriBuilder
-import java.lang.{Long => JLong}
-import java.util.{Map => JMap}
-
import scala.collection.mutable.ListBuffer
class VeloxSparkPlanExecApi extends SparkPlanExecApi {
- /**
- * Transform GetArrayItem to Substrait.
- *
- * arrCol[index] => IF(index < 0, null, ElementAt(arrCol, index + 1))
- */
- override def genGetArrayItemExpressionNode(
+ /** Transform GetArrayItem to Substrait. */
+ override def genGetArrayItemTransformer(
substraitExprName: String,
- functionMap: JMap[String, JLong],
- leftNode: ExpressionNode,
- rightNode: ExpressionNode,
- original: GetArrayItem): ExpressionNode = {
- if (original.dataType.isInstanceOf[DecimalType]) {
- val decimalType = original.dataType.asInstanceOf[DecimalType]
- val precision = decimalType.precision
- if (precision > 18) {
- throw new GlutenNotSupportException(
- "GetArrayItem not support decimal precision more than 18")
- }
- }
- // ignore origin substraitExprName
- val functionName = ConverterUtils.makeFuncName(
- ExpressionMappings.expressionsMap(classOf[ElementAt]),
- Seq(original.dataType),
- FunctionConfig.OPT)
- val exprNodes = Lists.newArrayList(leftNode, rightNode)
- val resultNode = ExpressionBuilder.makeScalarFunction(
- ExpressionBuilder.newScalarFunction(functionMap, functionName),
- exprNodes,
- ConverterUtils.getTypeNode(original.dataType, original.nullable))
- val nullNode = ExpressionBuilder.makeLiteral(null, original.dataType,
false)
- val lessThanFuncId = ExpressionBuilder.newScalarFunction(
- functionMap,
- ConverterUtils.makeFuncName(
- ExpressionNames.LESS_THAN,
- Seq(original.right.dataType, IntegerType),
- FunctionConfig.OPT))
- // right node already add 1
- val literalNode = ExpressionBuilder.makeLiteral(1.toInt, IntegerType,
false)
- val lessThanFuncNode = ExpressionBuilder.makeScalarFunction(
- lessThanFuncId,
- Lists.newArrayList(rightNode, literalNode),
- ConverterUtils.getTypeNode(BooleanType, true))
- new IfThenNode(Lists.newArrayList(lessThanFuncNode),
Lists.newArrayList(nullNode), resultNode)
+ left: ExpressionTransformer,
+ right: ExpressionTransformer,
+ original: Expression): ExpressionTransformer = {
+ GenericExpressionTransformer(substraitExprName, Seq(left, right), original)
Review Comment:
no, I have implement new version of GetArrayItem function in Velox which
align with Spark completely, and I move original code into CH module, you can
check PR description.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]