Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ object QueryPlanSerde extends Logging with CometExprShim {
case l @ Length(child) if child.dataType == BinaryType =>
withInfo(l, "Length on BinaryType is not supported")
None
case r @ Reverse(child) if child.dataType.isInstanceOf[ArrayType] =>
convert(r, CometArrayReverse)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use convert(expr, CometScalarFunction("array_reverse"))?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use convert(expr, CometScalarFunction("array_reve

Ignore this comment, I'm not sure which way we lean. cc @andygrove

case expr =>
QueryPlanSerde.exprSerdeMap.get(expr.getClass) match {
case Some(handler) =>
Expand Down
18 changes: 17 additions & 1 deletion spark/src/main/scala/org/apache/comet/serde/arrays.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package org.apache.comet.serde

import scala.annotation.tailrec

import org.apache.spark.sql.catalyst.expressions.{ArrayAppend, ArrayContains, ArrayDistinct, ArrayExcept, ArrayInsert, ArrayIntersect, ArrayJoin, ArrayMax, ArrayMin, ArrayRemove, ArrayRepeat, ArraysOverlap, ArrayUnion, Attribute, CreateArray, ElementAt, Expression, Flatten, GetArrayItem, Literal}
import org.apache.spark.sql.catalyst.expressions.{ArrayAppend, ArrayContains, ArrayDistinct, ArrayExcept, ArrayInsert, ArrayIntersect, ArrayJoin, ArrayMax, ArrayMin, ArrayRemove, ArrayRepeat, ArraysOverlap, ArrayUnion, Attribute, CreateArray, ElementAt, Expression, Flatten, GetArrayItem, Literal, Reverse}
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types._

Expand Down Expand Up @@ -432,6 +432,22 @@ object CometGetArrayItem extends CometExpressionSerde[GetArrayItem] {
}
}

object CometArrayReverse extends CometExpressionSerde[Reverse] with ArraysBase {
override def convert(
expr: Reverse,
inputs: Seq[Attribute],
binding: Boolean): Option[ExprOuterClass.Expr] = {
if (!isTypeSupported(expr.child.dataType)) {
withInfo(expr, s"child data type not supported: ${expr.child.dataType}")
return None
}
val reverseExprProto = exprToProto(expr.child, inputs, binding)
val reverseScalarExpr = scalarFunctionExprToProto("array_reverse", reverseExprProto)
optExprWithInfo(reverseScalarExpr, expr, expr.children: _*)
}

}

object CometElementAt extends CometExpressionSerde[ElementAt] {

override def convert(
Expand Down
Loading
Loading