ueshin opened a new pull request, #49631:
URL: https://github.com/apache/spark/pull/49631
### What changes were proposed in this pull request?
Fixes the usage of `Column.__new__`.
### Why are the changes needed?
Currently `Column.__init__` is called in `Column.__new__`, but it will call
`__init__` twice.
```py
>>> class A:
... def __new__(cls, *args, **kwargs):
... print(f"__NEW__: {args}, {kwargs}")
... obj = object.__new__(cls)
... obj.__init__(*args, **kwargs)
... return obj
... def __init__(self, *args, **kwargs):
... print(f"__INIT__: {args}, {kwargs}")
...
>>> A(1,2,3, k=4)
__NEW__: (1, 2, 3), {'k': 4}
__INIT__: (1, 2, 3), {'k': 4}
__INIT__: (1, 2, 3), {'k': 4}
<__main__.A object at 0x102ccab90>
>>> class B:
... def __new__(cls, *args, **kwargs):
... print(f"__NEW__: {args}, {kwargs}")
... return object.__new__(cls)
... def __init__(self, *args, **kwargs):
... print(f"__INIT__: {args}, {kwargs}")
...
>>> B(1,2,3, k=4)
__NEW__: (1, 2, 3), {'k': 4}
__INIT__: (1, 2, 3), {'k': 4}
<__main__.B object at 0x102b2b970>
```
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
The existing tests should pass.
### Was this patch authored or co-authored using generative AI tooling?
No.
--
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]