Github user JoshRosen commented on the pull request:
https://github.com/apache/spark/pull/6532#issuecomment-107136984
I guess the root cause of this bug was that the DecimalType class's
singleton-ness was inherited due to our use of metaclasses. In Scala, we
didn't have this problem because the singleton-ness was implemented at the
leaves of the class hierarchy by using `object`.
To prevent this sort of issue in the future, I wonder whether it would be
clearer to apply a decorator on the leaf class declarations themselves (as in
http://elbenshira.com/blog/singleton-pattern-in-python/) rather than using
metaclasses. It would be good to understand whether the difference between
these approaches has any performance / correctness impacts.
In the meantime, the fix here makes sense to me: we're just pushing the
singleton-ness a bit deeper into the class hierarchy so that it isn't
inappropriately inherited by DecimalType.
From a test coverage perspective, what tests would have caught this? It
seems that something as simple as just manually constructing an instance of
each type with all of its parameters specified would have caught this. Even
though it seems like an obvious / dumb test, maybe we should add a test that
just checks that we're able to instantiate each of the types that take
parameters.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]