maropu commented on a change in pull request #28184: [SPARK-31416][SQL] Check
more strictly that a field name can be used as a valid Java identifier for
codegen
URL: https://github.com/apache/spark/pull/28184#discussion_r407123755
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala
##########
@@ -539,9 +541,10 @@ object ScalaReflection extends ScalaReflection {
val params = getConstructorParameters(t)
val fields = params.map { case (fieldName, fieldType) =>
- if (javaKeywords.contains(fieldName)) {
- throw new UnsupportedOperationException(s"`$fieldName` is a
reserved keyword and " +
- "cannot be used as field name\n" + walkedTypePath)
+ if (SourceVersion.isKeyword(fieldName) ||
+
!SourceVersion.isIdentifier(encodeFieldNameToIdentifier(fieldName))) {
Review comment:
Yea, I know that. Not strong preference though, I found the style below in
this file;
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala#L283
```
if (XXXXX ||
YYYY) { // one more indent to tell a difference from <code block>
<code block>
}
```
So, I left the comment above for per-file style consistency. Anyway, trivial
though.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]