cloud-fan commented on a change in pull request #33599:
URL: https://github.com/apache/spark/pull/33599#discussion_r691297962
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala
##########
@@ -158,42 +158,46 @@ object ParserUtils {
}
}
- // Skip the first and last quotations enclosing the string literal.
- val charBuffer = CharBuffer.wrap(b, 1, b.length - 1)
-
- while (charBuffer.remaining() > 0) {
- charBuffer match {
- case U16_CHAR_PATTERN(cp) =>
- // \u0000 style 16-bit unicode character literals.
- sb.append(Integer.parseInt(cp, 16).toChar)
- charBuffer.position(charBuffer.position() + 6)
- case U32_CHAR_PATTERN(cp) =>
- // \U00000000 style 32-bit unicode character literals.
- // Use Long to treat codePoint as unsigned in the range of 32-bit.
- val codePoint = JLong.parseLong(cp, 16)
- if (codePoint < 0x10000) {
- sb.append((codePoint & 0xFFFF).toChar)
- } else {
- val highSurrogate = (codePoint - 0x10000) / 0x400 + 0xD800
- val lowSurrogate = (codePoint - 0x10000) % 0x400 + 0xDC00
- sb.append(highSurrogate.toChar)
- sb.append(lowSurrogate.toChar)
- }
- charBuffer.position(charBuffer.position() + 10)
- case OCTAL_CHAR_PATTERN(cp) =>
- // \000 style character literals.
- sb.append(Integer.parseInt(cp, 8).toChar)
- charBuffer.position(charBuffer.position() + 4)
- case ESCAPED_CHAR_PATTERN(c) =>
- // escaped character literals.
- appendEscapedChar(c.charAt(0))
- charBuffer.position(charBuffer.position() + 2)
- case _ =>
- // non-escaped character literals.
- sb.append(charBuffer.get())
+ if (b.matches("""(r|R)('|").*""")) {
Review comment:
is it more efficient to do `b.startsWith("r") || b.startsWith("R")`?
--
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]