coderfender commented on code in PR #4111:
URL: https://github.com/apache/datafusion-comet/pull/4111#discussion_r3163224336


##########
spark/src/main/scala/org/apache/comet/serde/strings.scala:
##########
@@ -42,13 +42,27 @@ object CometStringRepeat extends 
CometExpressionSerde[StringRepeat] {
       inputs: Seq[Attribute],
       binding: Boolean): Option[ExprOuterClass.Expr] = {
     val children = expr.children
+
+    children(1) match {
+      case Literal(count, _) if isNegativeNumber(count) =>
+        withInfo(expr, "Negative repeat count is not supported")
+        return None
+      case _ =>
+    }
+
     val leftCast = Cast(children(0), StringType)
     val rightCast = Cast(children(1), LongType)
     val leftExpr = exprToProtoInternal(leftCast, inputs, binding)
     val rightExpr = exprToProtoInternal(rightCast, inputs, binding)
     val optExpr = scalarFunctionExprToProto("repeat", leftExpr, rightExpr)
     optExprWithInfo(optExpr, expr, leftCast, rightCast)
   }
+
+  private def isNegativeNumber(value: Any): Boolean = value match {
+    case i: Int => i < 0
+    case l: Long => l < 0
+    case _ => false
+  }

Review Comment:
   added this method to be utilized later but can remove it if it is not needed 



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