Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/19082#discussion_r155999993 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala --- @@ -1070,6 +1071,24 @@ class CodegenContext { } } +object CodegenContext { + + private val javaKeywords = Set( + "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", + "continue", "default", "do", "double", "else", "extends", "false", "final", "finally", "float", + "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", + "new", "null", "package", "private", "protected", "public", "return", "short", "static", + "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", + "try", "void", "volatile", "while" + ) + + def isJavaIdentifier(str: String): Boolean = str match { + case null | "" => false + case _ => !javaKeywords.contains(str) && isJavaIdentifierStart(str.charAt(0)) && + (1 until str.length).forall(i => isJavaIdentifierPart(str.charAt(i))) + } --- End diff -- ```Scala /** * Returns true if the given `str` is a valid java identifier. */ def isJavaIdentifier(str: String): Boolean = str match { case null | "" => false case _ => !javaKeywords.contains(str) && isJavaIdentifierStart(str.charAt(0)) && (1 until str.length).forall(i => isJavaIdentifierPart(str.charAt(i))) } ```
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org