badalprasadsingh commented on code in PR #2779:
URL: https://github.com/apache/iceberg-go/pull/2779#discussion_r4782109122
##########
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:
here we have missed a major thing: for v3 files with row lineage,
`rewriteSingleFile` filters after type promotion and defaults, this check
filters before
a nested field with an initial default, or a float promoted to double, can
look unmatched, so its rows silently stay, better, check rows projected to the
full schema with tests
##########
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:
a filter like `i < 1<<40` on an int column with NULLs binds to AlwaysTrue,
so this scan selects no column and the delete fails with can't infer struct
array length -> this work right now on main
better: match the rows the rewrite drops instead, and add a test
--
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]