Skip to content

fix: SourceOperator is_source default broken by name mangling#5007

Open
Ma77Ball wants to merge 2 commits intoapache:mainfrom
Ma77Ball:fix/sourceOperatorNameMangling
Open

fix: SourceOperator is_source default broken by name mangling#5007
Ma77Ball wants to merge 2 commits intoapache:mainfrom
Ma77Ball:fix/sourceOperatorNameMangling

Conversation

@Ma77Ball
Copy link
Copy Markdown
Contributor

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:

  • Removed the bug-pinning test that asserted on the old mangled attribute names.
  • Removed the xfail marker from the contract test, which now passes: SourceOperator() reports is_source is True.

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

…s class-level override actually takes effect instead of creating a separate name-mangled attribute
@Ma77Ball
Copy link
Copy Markdown
Contributor Author

/request-review @aglinxinyuan

@github-actions github-actions Bot requested a review from aglinxinyuan May 10, 2026 03:41
@Ma77Ball Ma77Ball changed the title rename __internal_is_source to _internal_is_source so SourceOperator'… fix: SourceOperator is_source default broken by name mangling May 10, 2026
@chenlica chenlica requested review from Xiao-zhen-Liu and removed request for aglinxinyuan May 10, 2026 04:50
@chenlica
Copy link
Copy Markdown
Contributor

@Xiao-zhen-Liu Please review it.



class SourceOperator(TupleOperatorV2):
__internal_is_source = True
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still want it to be two underscores as prefix. Is it do able?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if the variable ends in double underline, e.g., --> __internal_is_source__

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python purposely makes it hard to access, as accessing these types of attribute names outside the class defeats the purpose of encapsulation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it that way for now.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.22%. Comparing base (410c700) to head (9031818).

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              
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 410c700
agent-service 33.72% <ø> (ø) Carriedforward from 410c700
amber 43.23% <ø> (ø) Carriedforward from 410c700
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 410c700
config-service 0.00% <ø> (ø) Carriedforward from 410c700
file-service 32.18% <ø> (ø) Carriedforward from 410c700
frontend 34.80% <ø> (ø) Carriedforward from 410c700
python 88.89% <100.00%> (-0.01%) ⬇️
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 410c700

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SourceOperator class-level __internal_is_source = True is dead due to name mangling

4 participants