-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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-32090][SQL] Improve UserDefinedType.equal() to make it be symmetrical #28923
Conversation
@cloud-fan @HyukjinKwon Please take a look, thanks! |
sql/core/src/test/scala/org/apache/spark/sql/UserDefinedTypeSuite.scala
Outdated
Show resolved
Hide resolved
Test build #124486 has finished for PR 28923 at commit
|
sql/core/src/test/scala/org/apache/spark/sql/UserDefinedTypeSuite.scala
Outdated
Show resolved
Hide resolved
LGTM except for the @cloud-fan comment. |
Retest this please. |
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.
+1 for @cloud-fan and @maropu 's comments.
Test build #124567 has finished for PR 28923 at commit
|
sql/core/src/test/scala/org/apache/spark/sql/UserDefinedTypeSuite.scala
Outdated
Show resolved
Hide resolved
The PR title, |
@dongjoon-hyun Updated the title, please take another look. |
Hi all, I've updated the PR according to your comments. Please take another look, thanks! |
Thank you, @Ngone51 and all. Today's 3 commits are only test case changes and I tested locally. The main body is already tested. Merged to master for Apache Spark 3.1.0. |
Test build #124617 has finished for PR 28923 at commit
|
thanks all!! |
…etrical ### What changes were proposed in this pull request? This PR fix `UserDefinedType.equal()` by comparing the UDT class instead of checking `acceptsType()`. ### Why are the changes needed? It's weird that equality comparison between two UDT types can have different result by switching the order: ```scala // ExampleSubTypeUDT.userClass is a subclass of ExampleBaseTypeUDT.userClass val udt1 = new ExampleBaseTypeUDT val udt2 = new ExampleSubTypeUDT println(udt1 == udt2) // true println(udt2 == udt1) // false ``` ### Does this PR introduce _any_ user-facing change? Yes. Before: ```scala // ExampleSubTypeUDT.userClass is a subclass of ExampleBaseTypeUDT.userClass val udt1 = new ExampleBaseTypeUDT val udt2 = new ExampleSubTypeUDT println(udt1 == udt2) // true println(udt2 == udt1) // false ``` After: ```scala // ExampleSubTypeUDT.userClass is a subclass of ExampleBaseTypeUDT.userClass val udt1 = new ExampleBaseTypeUDT val udt2 = new ExampleSubTypeUDT println(udt1 == udt2) // false println(udt2 == udt1) // false ``` ### How was this patch tested? Added a unit test. Closes #28923 from Ngone51/fix-udt-equal. Authored-by: yi.wu <yi.wu@databricks.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…etrical ### What changes were proposed in this pull request? This PR fix `UserDefinedType.equal()` by comparing the UDT class instead of checking `acceptsType()`. ### Why are the changes needed? It's weird that equality comparison between two UDT types can have different result by switching the order: ```scala // ExampleSubTypeUDT.userClass is a subclass of ExampleBaseTypeUDT.userClass val udt1 = new ExampleBaseTypeUDT val udt2 = new ExampleSubTypeUDT println(udt1 == udt2) // true println(udt2 == udt1) // false ``` ### Does this PR introduce _any_ user-facing change? Yes. Before: ```scala // ExampleSubTypeUDT.userClass is a subclass of ExampleBaseTypeUDT.userClass val udt1 = new ExampleBaseTypeUDT val udt2 = new ExampleSubTypeUDT println(udt1 == udt2) // true println(udt2 == udt1) // false ``` After: ```scala // ExampleSubTypeUDT.userClass is a subclass of ExampleBaseTypeUDT.userClass val udt1 = new ExampleBaseTypeUDT val udt2 = new ExampleSubTypeUDT println(udt1 == udt2) // false println(udt2 == udt1) // false ``` ### How was this patch tested? Added a unit test. Closes #28923 from Ngone51/fix-udt-equal. Authored-by: yi.wu <yi.wu@databricks.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
I've backported this into branch-3.0/2.4. For the reason, please see: https://github.com/apache/spark/pull/30157/files#r512494277 |
What changes were proposed in this pull request?
This PR fix
UserDefinedType.equal()
by comparing the UDT class instead of checkingacceptsType()
.Why are the changes needed?
It's weird that equality comparison between two UDT types can have different result by switching the order:
Does this PR introduce any user-facing change?
Yes.
Before:
After:
How was this patch tested?
Added a unit test.