riverandeye commented on code in PR #2779:
URL: https://github.com/apache/iceberg-go/pull/2779#discussion_r4796612004
##########
table/transaction_delete.go:
##########
@@ -663,13 +669,24 @@ func (t *Transaction) rewriteFilesWithFilter(ctx
context.Context, fs io.IO, upda
// non-trivial so doing it inside the iterator loop wastes work.
postFilter, err := prepareBatchFilter(complementFilter,
meta.CurrentSchema(), caseSensitive)
if err != nil {
- return err
+ return nil, err
}
+ var rewritten []iceberg.DataFile
for _, entry := range entries {
task, err := fileScanTaskForDataEntry(entry,
deletes.positional, deletes.dvs, deletes.equality)
if err != nil {
- return err
+ return nil, err
+ }
+
+ // The classifier only knows the filter might match from the
file's metrics.
+ // Rewriting a file the filter matches no row of would copy it
unchanged.
+ matched, err := hasMatchingRow(ctx, matchScan, task)
Review Comment:
Good catch, thanks. Fixed. For a rewrite that keeps row lineage, the check
now reads the file projected to the table schema and applies the same survivor
filter after the scan. Added tests for a promoted float and a nested default.
##########
table/transaction_delete.go:
##########
@@ -645,16 +644,23 @@ func (t *Transaction) readLiveDeletionVectors(ctx
context.Context, fs io.IO) (li
// rewriteFilesWithFilter rewrites data files by preserving only rows that do
NOT match the filter.
// Rows already removed by a delete are dropped too, since those deletes stop
applying once the file is replaced.
+// A file whose metrics only suggest a match but that holds no live row
matching the filter is kept as it is.
+// It returns the data files it replaced.
// The filter binding and substrait conversion are computed once here and
reused across every file.
-func (t *Transaction) rewriteFilesWithFilter(ctx context.Context, fs io.IO,
updater *snapshotProducer, builtMeta Metadata, deletes planningDeletes, entries
[]iceberg.ManifestEntry, filter iceberg.BooleanExpression, caseSensitive bool,
concurrency int) error {
+func (t *Transaction) rewriteFilesWithFilter(ctx context.Context, fs io.IO,
updater *snapshotProducer, builtMeta Metadata, deletes planningDeletes, entries
[]iceberg.ManifestEntry, filter iceberg.BooleanExpression, caseSensitive bool,
concurrency int) ([]iceberg.DataFile, error) {
meta, err := t.txnMeta()
if err != nil {
- return err
+ return nil, err
}
complementFilter, err := isNotTrueExpr(filter)
if err != nil {
- return fmt.Errorf("failed to build complement filter: %w", err)
+ return nil, fmt.Errorf("failed to build complement filter: %w",
err)
+ }
+
+ matchScan, err := newMatchingRowScan(fs, builtMeta,
meta.CurrentSchema(), filter, caseSensitive, concurrency)
Review Comment:
Confirmed, thanks. The check now uses the negated survivor filter, so it
selects exactly the rows the rewrite drops. Added a test for `i < 1<<40` on a
nullable int column.
##########
table/transaction_delete.go:
##########
@@ -645,16 +644,23 @@ func (t *Transaction) readLiveDeletionVectors(ctx
context.Context, fs io.IO) (li
// rewriteFilesWithFilter rewrites data files by preserving only rows that do
NOT match the filter.
// Rows already removed by a delete are dropped too, since those deletes stop
applying once the file is replaced.
+// A file whose metrics only suggest a match but that holds no live row
matching the filter is kept as it is.
+// It returns the data files it replaced.
Review Comment:
Updated all six.
--
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]