kazuyukitanimura commented on code in PR #1470:
URL: https://github.com/apache/datafusion-comet/pull/1470#discussion_r1978347424


##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -2122,6 +2122,22 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
     }
   }
 
+  test("pad") {
+    val table = "pad"
+    val gen = new DataGenerator(new Random(42))
+    withTable(table) {
+      // generate some data
+      // newline characters are intentionally omitted for now
+      val dataChars = "\t abc123"
+      sql(s"create table $table(id int, name varchar(20)) using parquet")
+      gen.generateStrings(100, dataChars, 6).zipWithIndex.foreach { x =>
+        sql(s"insert into $table values(${x._2}, '${x._1}')")

Review Comment:
   Can we cover the same cases as 
https://github.com/apache/datafusion-comet/blob/main/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala#L2115
   especially those unicode cases?



##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -1586,6 +1586,18 @@ object QueryPlanSerde extends Logging with 
ShimQueryPlanSerde with CometExprShim
       case StringTrimBoth(srcStr, trimStr, _) =>
         trim(expr, srcStr, trimStr, inputs, binding, "btrim")
 
+      case StringLPad(srcStr, size, chars) =>
+        val arg0 = exprToProtoInternal(srcStr, inputs, binding)
+        val arg1 = exprToProtoInternal(Cast(size, LongType), inputs, binding)
+        val arg2 = exprToProtoInternal(chars, inputs, binding)
+        scalarExprToProto("lpad", arg0, arg1, arg2)
+
+      case StringRPad(srcStr, size, chars) =>
+        val arg0 = exprToProtoInternal(srcStr, inputs, binding)
+        val arg1 = exprToProtoInternal(Cast(size, LongType), inputs, binding)
+        val arg2 = exprToProtoInternal(chars, inputs, binding)
+        scalarExprToProto("rpad", arg0, arg1, arg2)

Review Comment:
   I remember that DataFusion rpad truncates the string if it is already longer 
than the `size`. Could you add a test if Spark behaves the same?



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to