wangyum commented on a change in pull request #34313:
URL: https://github.com/apache/spark/pull/34313#discussion_r732523697



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
##########
@@ -1701,13 +1701,9 @@ case class FormatString(children: Expression*) extends 
Expression with ImplicitC
    * Therefore, manually check that the pattern string not contains "%0$" to 
ensure consistent
    * behavior of Java 8, Java 11 and Java 17.
    */
-  private def checkArgumentIndexNotZero(expression: Expression): Boolean = {
-    val pattern = expression.eval(null)
-    if (pattern == null) {
-      true
-    } else {
-      !pattern.asInstanceOf[UTF8String].toString.contains("%0$")
-    }
+  private def checkArgumentIndexNotZero(expression: Expression): Boolean = 
expression match {
+    case pattern: Literal if pattern.dataType == StringType => 
!pattern.toString.contains("%0$")

Review comment:
       `case StringLiteral(pattern) => !pattern.contains("%0$")`?




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