Skip to content

Commit bd6b9fa

Browse files
wForgetandygrove
andauthored
fix: Fallback length function with non-string input (#2349)
Co-authored-by: Andy Grove <[email protected]>
1 parent f2baf95 commit bd6b9fa

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,9 @@ object QueryPlanSerde extends Logging with CometExprShim {
10261026
}
10271027
case af @ ArrayFilter(_, func) if func.children.head.isInstanceOf[IsNotNull] =>
10281028
convert(af, CometArrayCompact)
1029+
case l @ Length(child) if child.dataType == BinaryType =>
1030+
withInfo(l, "Length on BinaryType is not supported")
1031+
None
10291032
case expr =>
10301033
QueryPlanSerde.exprSerdeMap.get(expr.getClass) match {
10311034
case Some(handler) =>

spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,4 +2953,14 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
29532953
}
29542954
}
29552955

2956+
test("test length function") {
2957+
withTable("t1") {
2958+
sql(
2959+
"create table t1 using parquet as select cast(id as string) as c1, cast(id as binary) as c2 from range(10)")
2960+
// FIXME: Change checkSparkAnswer to checkSparkAnswerAndOperator after resolving
2961+
// https://github.com/apache/datafusion-comet/issues/2348
2962+
checkSparkAnswer("select length(c1), length(c2) AS x FROM t1 ORDER BY c1")
2963+
}
2964+
}
2965+
29562966
}

0 commit comments

Comments
 (0)