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

   ### What changes were proposed in this pull request?
   
   Spark Declarative Pipelines now removes a table property from the 
materialized table when the property is dropped from the dataset definition 
between runs.
   
   - `PipelinesTableProperties` adds an internal table property, 
`pipelines.declaredPropertyKeys`. It records, as a JSON string array, the keys 
of the table properties declared in the dataset definition at the latest 
materialization. A JSON codec is added for its value.
   - `DatasetManager.resolveTableProperties` writes this record on every create 
and evolve. The record covers only keys from the definition's 
`table_properties`. It does not cover properties derived from `comment` or 
`format`.
   - `DatasetManager.evolveTable` reads the record from the existing table. It 
issues a `TableChange.removeProperty` for every recorded key that meets all of 
these conditions:
     - it is no longer declared;
     - it is still present on the table;
     - it is not a reserved catalog property 
(`CatalogV2Util.TABLE_RESERVED_PROPERTIES`).
   
     The removals go in the same `alterTable` call as the schema changes and 
the property updates.
   - Properties the pipeline never declared are left untouched. This covers 
catalog-managed keys such as `clusteringColumns` and properties set outside the 
pipeline.
   - A table with no record has nothing removed. This covers tables 
materialized before this change. The record is written on that run, and 
removals apply from the next run on.
   - `pipelines.declaredPropertyKeys` is not a registered user-settable 
property, so `validateAndCanonicalize` drops a value the user declares for it.
   - Auxiliary AutoCDC tables never carry the record, so their behavior does 
not change.
   
   The latest definition that materializes a table decides which property keys 
are recorded on it.
   
   ### Why are the changes needed?
   
   Table property evolution was additive only. A property removed from the 
dataset definition stayed on the materialized table forever, so the table no 
longer matched its definition. The property could not simply be diffed against 
the table's current properties: the table can carry catalog-managed or 
externally set properties that must not be removed. Recording which keys the 
pipeline declared makes it possible to remove only those.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes.
   - A table property removed from a materialized view or streaming table 
definition is now removed from the table on the next pipeline run. Previously 
it was kept.
   - Pipeline-materialized tables now carry the internal table property 
`pipelines.declaredPropertyKeys`, which is visible in `SHOW TBLPROPERTIES`.
   
   ### How was this patch tested?
   
   New and updated tests in `MaterializeTablesSuite`:
   - A dropped property is removed, while a property set outside the pipeline 
is kept.
   - Dropping all properties removes them. The next run with no changes then 
issues no `alterTable`.
   - A table without the declared-keys record has nothing removed, and the 
record is bootstrapped.
   - A user-declared value for `pipelines.declaredPropertyKeys` is ignored.
   - A dropped property is removed from a materialized view.
   - The changed/new properties test now expects the declared-keys record 
update.
   - The previous test that locked in the additive-only behavior is replaced.
   
   The new tests fail without the fix. `build/sbt pipelines/test`, 
`pipelines/scalastyle`, and `pipelines/Test/scalastyle` pass.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   
   This pull request and its description were written by Isaac.
   


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