Skip to content

Commit

Permalink
fix: Unsupported window expression should fall back to Spark (apache#710
Browse files Browse the repository at this point in the history
)
  • Loading branch information
viirya authored Jul 24, 2024
1 parent d4a8d68 commit 4423941
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2535,8 +2535,12 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
}
}.toArray

val windowExprProto = winExprs.map(windowExprToProto(_, output))
if (winExprs.length != windowExpression.length) {
withInfo(op, "Unsupported window expression(s)")
return None
}

val windowExprProto = winExprs.map(windowExprToProto(_, output))
val partitionExprs = partitionSpec.map(exprToProto(_, child.output))

val sortOrders = orderSpec.map(exprToProto(_, child.output))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ class CometExecSuite extends CometTestBase {
}
}

test("Unsupported window expression should fall back to Spark") {
checkAnswer(
spark.sql("select sum(a) over () from values 1.0, 2.0, 3.0 T(a)"),
Row(6.0) :: Row(6.0) :: Row(6.0) :: Nil)
checkAnswer(
spark.sql("select avg(a) over () from values 1.0, 2.0, 3.0 T(a)"),
Row(2.0) :: Row(2.0) :: Row(2.0) :: Nil)
}

test("fix CometNativeExec.doCanonicalize for ReusedExchangeExec") {
assume(isSpark34Plus, "ChunkedByteBuffer is not serializable before Spark 3.4+")
withSQLConf(
Expand Down

0 comments on commit 4423941

Please sign in to comment.