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/01/12 14:48:05 UTC

[GitHub] [spark] srowen commented on a change in pull request #31096: [SPARK-34051][SQL] Support 32-bit unicode escape in string literals

srowen commented on a change in pull request #31096:
URL: https://github.com/apache/spark/pull/31096#discussion_r555826624



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala
##########
@@ -172,6 +172,20 @@ object ParserUtils {
           }
           sb.append(code.asInstanceOf[Char])
           i += 5
+        } else if ((i + 10 < strLength) && b.charAt(i + 1) == 'U' &&
+                   (2 until 10).forall(j => Character.digit(b.charAt(i + j), 16) != -1)) {
+          // \U00000000 style 32-bit unicode character literals.
+
+          val codePoint = Integer.parseInt(b.substring(i + 2, i + 10), 16)

Review comment:
       Actually, a comment: Do you need to treat this as 'unsigned'? if it's more than 2^31 - 1, then it will become negative, and I'm not sure checks below work.

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala
##########
@@ -172,6 +172,20 @@ object ParserUtils {
           }
           sb.append(code.asInstanceOf[Char])
           i += 5
+        } else if ((i + 10 < strLength) && b.charAt(i + 1) == 'U' &&

Review comment:
       We could use a regex here too; might be faster. But if this isn't a hot path, probably won't matter.




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

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