hsiang-c commented on code in PR #2630:
URL: https://github.com/apache/datafusion-comet/pull/2630#discussion_r2457780573


##########
spark/src/test/scala/org/apache/comet/CometStringExpressionSuite.scala:
##########
@@ -19,12 +19,81 @@
 
 package org.apache.comet
 
+import scala.util.Random
+
 import org.apache.parquet.hadoop.ParquetOutputFormat
 import org.apache.spark.sql.{CometTestBase, DataFrame}
 import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.types.{DataTypes, StructField, StructType}
+
+import org.apache.comet.testing.{DataGenOptions, FuzzDataGenerator}
 
 class CometStringExpressionSuite extends CometTestBase {
 
+  test("lpad") {
+    testPadding("lpad")
+  }
+
+  test("rpad") {
+    testPadding("rpad")
+  }
+
+  private def testPadding(expr: String): Unit = {
+    val r = new Random(42)
+    val schema = StructType(
+      Seq(
+        StructField("str", DataTypes.StringType, nullable = true),
+        StructField("len", DataTypes.IntegerType, nullable = true),
+        StructField("pad", DataTypes.StringType, nullable = true)))
+    // scalastyle:off
+    val edgeCases = Seq(
+      "é", // unicode 'e\\u{301}'
+      "é", // unicode '\\u{e9}'
+      "తెలుగు")
+    // scalastyle:on
+    val df = FuzzDataGenerator.generateDataFrame(
+      r,
+      spark,
+      schema,
+      1000,
+      DataGenOptions(maxStringLength = 6, customStrings = edgeCases))
+    df.createOrReplaceTempView("t1")
+
+    // test all combinations of scalar and array arguments
+    for (str <- Seq("'hello'", "str")) {

Review Comment:
   Spark [doc](https://spark.apache.org/docs/latest/api/sql/index.html#rpad) 
says it also supports binary string: `unhex('aabb')`



-- 
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]

Reply via email to