Skip to content
Draft
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 @@ -163,6 +163,7 @@ object QueryPlanSerde extends Logging with CometExprShim {
classOf[BitLength] -> CometScalarFunction("bit_length"),
classOf[Chr] -> CometScalarFunction("char"),
classOf[ConcatWs] -> CometScalarFunction("concat_ws"),
classOf[Concat] -> CometScalarFunction("concat"),
classOf[Contains] -> CometScalarFunction("contains"),
classOf[EndsWith] -> CometScalarFunction("ends_with"),
classOf[InitCap] -> CometInitCap,
Expand Down
11 changes: 11 additions & 0 deletions spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3204,4 +3204,15 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
}
}

test("test concat function - strings") {
Copy link
Member

Choose a reason for hiding this comment

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

Concat supports other types as well:

private def allowedTypes: Seq[AbstractDataType] = Seq(StringType, BinaryType, ArrayType)

Copy link
Contributor Author

@comphead comphead Oct 21, 2025

Choose a reason for hiding this comment

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

Thanks @andygrove this PR for string only
ArrayType waits for apache/datafusion#18020

I dont see binary type support though https://spark.apache.org/docs/latest/api/sql/#concat

UPD: Binary it is probably a specific case of array concat

scala> spark.sql("select concat(to_binary('abc'), to_binary('def'))").show(false)
+--------------------------------------+
|concat(to_binary(abc), to_binary(def))|
+--------------------------------------+
|[0A BC 0D EF]                         |
+--------------------------------------+

I'll check this

withTable("t1") {
sql(
"create table t1 using parquet as select uuid() c1, uuid() c2, uuid() c3, uuid() c4, cast(null as string) c5 from range(10)")
checkSparkAnswerAndOperator("select concat(c1, c2) AS x FROM t1")
checkSparkAnswerAndOperator("select concat(c1, c2, c3) AS x FROM t1")
checkSparkAnswerAndOperator("select concat(c1, c2, c3, c5) AS x FROM t1")
//checkSparkAnswerAndOperator("select concat(concat(c1, c2, c3), concat(c1, c3)) AS x FROM t1")
}
}

}
Loading