smaheshwar-pltr commented on code in PR #3220:
URL: https://github.com/apache/iceberg-python/pull/3220#discussion_r3269595359


##########
mkdocs/docs/api.md:
##########
@@ -185,6 +185,21 @@ with 
catalog.create_table_transaction(identifier="docs_example.bids", schema=sch
     txn.set_properties(test_a="test_aa", test_b="test_b", test_c="test_c")
 ```
 
+## Replace a table
+
+Atomically replace an existing table's schema, partition spec, sort order, 
location, and properties via `replace_table_transaction`. The table UUID and 
history (snapshots, schemas, specs, sort orders, metadata log) are preserved; 
the current snapshot is cleared (the `main` branch ref is removed). Open the 
transaction with the new definition, stage any additional changes (writes, 
property updates, schema evolution), and commit — for example, an RTAS 
(replace-table-as-select) that swaps the schema and writes the new data 
atomically:
+
+```python
+with catalog.replace_table_transaction(identifier="docs_example.bids", 
schema=df.schema) as txn:
+    txn.append(df)

Review Comment:
   I went back and forth on adding a top-level `Catalog.replace_table` in this 
PR.
   
   Iceberg Java _doesn't_ support this catalog API — its 
`Catalog.newReplaceTableTransaction(...)` and 
`TableBuilder.replaceTransaction()` both return a `Transaction` you have to 
`.commitTransaction()` yourself..
   
   I decided to drop support for this in 5b4a49ab because adding to `Catalog`'s 
public surface felt contentious, and we can always add it as a follow-up if 
folks want to, keeping this PR smaller, simpler and isolated too.



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