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 2022/02/11 03:34:44 UTC

[GitHub] [spark] TongWei1105 commented on a change in pull request #35476: [SPARK-38173][SQL] Quoted column cannot be recognized correctly when quotedRegexColumnNa…

TongWei1105 commented on a change in pull request #35476:
URL: https://github.com/apache/spark/pull/35476#discussion_r804337957



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -2085,12 +2085,23 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with SQLConfHelper with Logg
   private def canApplyRegex(ctx: ParserRuleContext): Boolean = withOrigin(ctx) {
     var parent = ctx.getParent
     while (parent != null) {
-      if (parent.isInstanceOf[NamedExpressionContext]) return true
+      if (parent.isInstanceOf[NamedExpressionContext] && isRegex(ctx.getText)) return true
       parent = parent.getParent
     }
     return false
   }
 
+  /**
+   * Returns whether the pattern is a regex expression (instead of a normal
+   * string). Normal string is a string with all alphabets/digits and "_".
+   */
+  private def isRegex(pattern: String): Boolean = {
+    for (p <- pattern) {
+      if (!Character.isLetterOrDigit(p) && p != '_') return true
+    }

Review comment:
       done




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