dttung2905 commented on code in PR #482:
URL: https://github.com/apache/iceberg-go/pull/482#discussion_r2648591188
##########
table/transaction.go:
##########
@@ -343,6 +345,250 @@ func (t *Transaction) AddFiles(ctx context.Context, files
[]string, snapshotProp
return t.apply(updates, reqs)
}
+// DynamicPartitionOverwrite performs a dynamic partition overwrite operation.
+// It detects partition values in the provided arrow table using the current
+// partition spec, deletes existing partitions matching these values, and then
+// appends the new data.
+func (t *Transaction) DynamicPartitionOverwrite(ctx context.Context, tbl
arrow.Table, batchSize int64, snapshotProps iceberg.Properties) error {
+ if t.meta.CurrentSpec().IsUnpartitioned() {
+ return fmt.Errorf("%w: cannot apply dynamic overwrite on an
unpartitioned table", ErrInvalidOperation)
+ }
+
+ // Check that all partition fields use identity transforms
+ currentSpec := t.meta.CurrentSpec()
+ for field := range currentSpec.Fields() {
+ if _, ok := field.Transform.(iceberg.IdentityTransform); !ok {
+ return fmt.Errorf("%w: dynamic overwrite does not
support non-identity-transform fields in partition spec: %s",
+ ErrInvalidOperation, field.Name)
+ }
+ }
+
+ if tbl.NumRows() == 0 {
+ return nil
+ }
Review Comment:
cmiiw but in the spark writer is it quite similar
https://github.com/apache/iceberg/blob/0651b8913d27c3b1c9aca4a9609bec521905fb36/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/source/SparkWrite.java#L297-L305
wdyt 🤔 ?
--
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]