You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/10/20 08:17:09 UTC

[GitHub] [spark] wangyum commented on a change in pull request #34313: [SPARK-37013][SQL] Ensure `format_string` has same behavior when using Java 8 and Java 17

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: reviews-unsubscribe@spark.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org