fix: SourceOperator is_source default broken by name mangling#5007
fix: SourceOperator is_source default broken by name mangling#5007Ma77Ball wants to merge 2 commits intoapache:mainfrom
Conversation
…s class-level override actually takes effect instead of creating a separate name-mangled attribute
|
/request-review @aglinxinyuan |
|
@Xiao-zhen-Liu Please review it. |
|
|
||
|
|
||
| class SourceOperator(TupleOperatorV2): | ||
| __internal_is_source = True |
There was a problem hiding this comment.
I still want it to be two underscores as prefix. Is it do able?
There was a problem hiding this comment.
Only if the variable ends in double underline, e.g., --> __internal_is_source__
There was a problem hiding this comment.
Python purposely makes it hard to access, as accessing these types of attribute names outside the class defeats the purpose of encapsulation.
There was a problem hiding this comment.
yes that's the purpose of using two underscores. I hope to prevent this field from being accessed. but source operator this field should be set to True. can we find a compromise between those requirements?
There was a problem hiding this comment.
There is no way to change how Python handles mangled classes to make this work. However we can just literally spell the mangled name _Operator__internal_is_source = True in SourceOperator. If this is preferred, I can add the change.
There was a problem hiding this comment.
Let's do it that way for now.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5007 +/- ##
============================================
- Coverage 43.22% 43.22% -0.01%
Complexity 2183 2183
============================================
Files 1035 1035
Lines 38814 38813 -1
Branches 4061 4061
============================================
- Hits 16777 16776 -1
Misses 20985 20985
Partials 1052 1052
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What changes were proposed in this PR?
Fixes a name-mangling bug in amber/src/main/python/core/models/operator.py.
Operator declared __internal_is_source (double underscore), which Python rewrites per class. So SourceOperator.__internal_is_source = True was stored as _SourceOperator__internal_is_source, while the property kept reading _Operator__internal_is_source. Result: SourceOperator subclasses defaulted to is_source = False, and only worked because ExecutorManager called the setter afterward.
Fix: rename to _internal_is_source (single underscore, no mangling) in Operator's class attribute, getter, setter, and SourceOperator's override. Also removed a dead, mangled line in TableOperator.init.
Any related issues, documentation, or discussions?
Closes: #4736
How was this PR tested?
Updated amber/src/test/python/core/models/test_operator.py:
All 29 tests in test_operator.py pass.
Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.7 in Compliance with ASF