badalprasadsingh commented on code in PR #2709:
URL: https://github.com/apache/iceberg-go/pull/2709#discussion_r4704968201
##########
table/empty_string_partition_scan_test.go:
##########
@@ -83,3 +83,56 @@ func TestEmptyStringIdentityPartitionScans(t *testing.T) {
})
}
}
+
+// A file whose string column holds only "" must keep "" as both bounds, so
+// scans can skip it for any other value.
+func TestEmptyStringBoundsPruneScans(t *testing.T) {
+ ctx := context.Background()
+ cat, err := hadoop.NewCatalog(ctx, "local", t.TempDir(), nil)
+ require.NoError(t, err)
+ require.NoError(t, cat.CreateNamespace(ctx, catalog.ToIdentifier("db"),
nil))
+
+ schema := iceberg.NewSchema(0,
+ iceberg.NestedField{ID: 1, Name: "id", Type:
iceberg.PrimitiveTypes.Int64, Required: true},
+ iceberg.NestedField{ID: 2, Name: "s", Type:
iceberg.PrimitiveTypes.String},
+ )
+ tbl, err := cat.CreateTable(ctx, catalog.ToIdentifier("db", "events"),
schema)
+ require.NoError(t, err)
+
+ arrowSchema, err := table.SchemaToArrowSchema(schema, nil, false, false)
+ require.NoError(t, err)
+ builder := array.NewRecordBuilder(memory.DefaultAllocator, arrowSchema)
+ defer builder.Release()
+ builder.Field(0).(*array.Int64Builder).AppendValues([]int64{1, 2}, nil)
+ builder.Field(1).(*array.StringBuilder).AppendValues([]string{"", ""},
nil)
+
+ record := builder.NewRecordBatch()
+ defer record.Release()
+ reader, err := array.NewRecordReader(arrowSchema,
[]arrow.RecordBatch{record})
+ require.NoError(t, err)
+ defer reader.Release()
+ tbl, err = tbl.Append(ctx, reader, nil)
+ require.NoError(t, err)
+
+ tasks, err := tbl.Scan().PlanFiles(ctx)
+ require.NoError(t, err)
+ require.Len(t, tasks, 1)
+ require.Equal(t, []byte{}, tasks[0].File.LowerBoundValues()[2])
+ require.Equal(t, []byte{}, tasks[0].File.UpperBoundValues()[2])
+
+ for _, tc := range []struct {
+ name string
+ expr iceberg.BooleanExpression
+ files int
+ }{
+ {name: "equal to empty", expr:
iceberg.EqualTo(iceberg.Reference("s"), ""), files: 1},
+ {name: "equal to other", expr:
iceberg.EqualTo(iceberg.Reference("s"), "zz"), files: 0},
+ {name: "greater than", expr:
iceberg.GreaterThan(iceberg.Reference("s"), "a"), files: 0},
Review Comment:
we are missing the "startsWith" case, check "VisitStartsWith"
"startsWith" still ignores an empty upper bound: drop the `len>0` check and
add the case in test
you can add it here, or good as a follow-up as well
--
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]