-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-13540][SQL] Supports using nested classes within Scala objects as Dataset element type #11421
[SPARK-13540][SQL] Supports using nested classes within Scala objects as Dataset element type #11421
Conversation
cc @cloud-fan |
Test build #52147 has finished for PR 11421 at commit
|
Test build #52148 has finished for PR 11421 at commit
|
@@ -559,7 +561,10 @@ class Analyzer( | |||
} | |||
|
|||
resolveExpression(unbound, LocalRelation(attributes), throws = true) transform { | |||
case n: NewInstance if n.outerPointer.isEmpty && n.cls.isMemberClass => | |||
case n: NewInstance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be great to add some inline documentation what about these conditions are checking
Thanks for the review! Comments addressed. |
case n: NewInstance if n.outerPointer.isEmpty && n.cls.isMemberClass => | ||
case n: NewInstance | ||
// If this is an inner class of another class, register the outer object in `OuterScopes`. | ||
// Note that static inner classes (e.g., inner classes within Scala objects. don't need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: (e.g. inner classes within Scala objects)
LGTM except some minor comments. |
28e1139
to
4ce71ce
Compare
Test build #52164 has finished for PR 11421 at commit
|
retest this please |
Test build #52171 has finished for PR 11421 at commit
|
4ce71ce
to
e707881
Compare
Test build #52173 has finished for PR 11421 at commit
|
Test build #52178 has finished for PR 11421 at commit
|
retest this please. |
Test build #52185 has finished for PR 11421 at commit
|
I'm merging this to master as it blocks #11431. |
… as Dataset element type ## What changes were proposed in this pull request? Nested classes defined within Scala objects are translated into Java static nested classes. Unlike inner classes, they don't need outer scopes. But the analyzer still thinks that an outer scope is required. This PR fixes this issue simply by checking whether a nested class is static before looking up its outer scope. ## How was this patch tested? A test case is added to `DatasetSuite`. It checks contents of a Dataset whose element type is a nested class declared in a Scala object. Author: Cheng Lian <[email protected]> Closes apache#11421 from liancheng/spark-13540-object-as-outer-scope.
What changes were proposed in this pull request?
Nested classes defined within Scala objects are translated into Java static nested classes. Unlike inner classes, they don't need outer scopes. But the analyzer still thinks that an outer scope is required.
This PR fixes this issue simply by checking whether a nested class is static before looking up its outer scope.
How was this patch tested?
A test case is added to
DatasetSuite
. It checks contents of a Dataset whose element type is a nested class declared in a Scala object.