yyanyy opened a new pull request, #59330:
URL: https://github.com/apache/spark/pull/59330

   ### What changes were proposed in this pull request?
   
   This pull request preserves `TreeNode` tags when a `DataSourceV2Relation` is 
rebuilt in two places:
   
   * `DataSourceV2Relation.withMetadataColumns`
   * `Analyzer.ResolveOutputRelation` when it cleans and marks a DataSource V2 
write target
   
   It also adds regression tests for both rebuild paths.
   
   ### Why are the changes needed?
   
   These paths use the Scala case-class `copy` method directly. Unlike 
`TreeNode.makeCopy` and the tree transformation helpers, the generated `copy` 
method does not call `copyTagsFrom`. As a result, tags attached to the original 
relation are silently absent from the rebuilt relation.
   
   Preserving the tags is consistent with the existing 
`LogicalRelation.withMetadataColumns` behavior and with the `TreeNode` contract 
for semantically equivalent replacements.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This change preserves internal logical-plan metadata.
   
   ### How was this patch tested?
   
   Added the following regression tests:
   
   * `DataSourceV2RelationSuite: withMetadataColumns preserves tags`
   * `V2ResolveOutputRelationSuite: ResolveOutputRelation preserves tags on a 
rebuilt DSv2 write target`
   
   Before the production changes, each new test failed because the rebuilt 
relation had no tag. After the changes, the two relevant suites completed with 
30 tests succeeded and 0 failed:
   
   `build/sbt 'catalyst/testOnly 
org.apache.spark.sql.execution.datasources.v2.DataSourceV2RelationSuite 
org.apache.spark.sql.catalyst.analysis.V2ResolveOutputRelationSuite'`
   
   The Catalyst compile and test scalastyle checks also passed with 0 errors:
   
   `build/sbt 'catalyst/scalastyle' 'catalyst/Test/scalastyle'`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex
   


-- 
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]

Reply via email to