Skip to content

Conversation

ksbeyer
Copy link
Contributor

@ksbeyer ksbeyer commented Sep 25, 2025

What changes were proposed in this pull request?

Improve how metadata is propagated during analysis and rewrites.

  • applyColumnMetadata: tried to avoid an Alias but the caused incorrect propagation.
  • collapseAlias and trimNonTopLevelAliases: now preserves the meaning of stacked aliases.
  • removeRedundantAlias: will remove a redundant alias when the only extra key is AUTO_GENERATED_ALIAS.
  • other minor cleanup

This PR improves metadata propagation but it doesn't solve all the problems. A thorough review is recommended. Also recommended is to make and Alias unresolved if its inferring metadata and once its child is resolved, the ineferred metadata should be made explicit. Then the metadata would be significantly more stable.

Why are the changes needed?

Wrong metadata is inferred for DML and probably other places.

Does this PR introduce any user-facing change?

Changing metadata can change DML behavior.
Not removing aliases can cause some Project operators to remain.

How was this patch tested?

Tests were added with the previous PR on this topic [SPARK-52772].

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions github-actions bot added the SQL label Sep 25, 2025
@ksbeyer ksbeyer changed the title [SPARK-53707] Improve attribute metadata handling. [WIP][SPARK-53707] Improve attribute metadata handling. Sep 25, 2025
@ksbeyer ksbeyer force-pushed the SPARK-53707-better-metadata branch 3 times, most recently from 9c2fd9d to e0156d8 Compare September 26, 2025 04:33
 thetasketch.sql.out is outdated expected from recursive sql changes; fixing it too
@ksbeyer ksbeyer force-pushed the SPARK-53707-better-metadata branch from e0156d8 to 3c94b46 Compare September 26, 2025 05:12
@ksbeyer ksbeyer changed the title [WIP][SPARK-53707] Improve attribute metadata handling. [SPARK-53707] Improve attribute metadata handling. Sep 26, 2025
@cloud-fan
Copy link
Contributor

thanks, merging to master!

@pan3793
Copy link
Member

pan3793 commented Sep 29, 2025

@ksbeyer @cloud-fan, this patch seems to have fixed another issue I'm working on #52474 (comment). I'm not sure if it's by design or just a side effect.

@cloud-fan
Copy link
Contributor

cloud-fan commented Sep 29, 2025

This PR fixes attribute metadata propagation (keeps more Alias), not sure if it's related to the planned write bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants