Copilot commented on code in PR #2445:
URL: https://github.com/apache/iceberg-go/pull/2445#discussion_r4605742782


##########
table/equality_delete_bytes_fastpath_test.go:
##########
@@ -265,6 +265,182 @@ func TestProcessEqualityDeletesSingleBytesDictionary(t 
*testing.T) {
        }
 }
 
+func TestProcessEqualityDeletesSingleBytesDictionaryAcrossBatches(t 
*testing.T) {
+       const apple, null = "\x01\x00\x00\x00\x05apple", "\x00"
+       type batch struct {
+               dictionary string
+               indices    string
+               offset     int
+               wantIDs    []int64
+       }
+       tests := []struct {
+               name         string
+               dictionaries map[string]string
+               // dictionaryOffset slices this many leading values off every 
dictionary.
+               dictionaryOffset int
+               sets             [][]string
+               batches          []batch
+       }{
+               {
+                       name:         "different_dictionary_same_length",
+                       dictionaries: map[string]string{"a": `["apple", "bob", 
"cherry"]`, "b": `["bob", "apple", "cherry"]`},
+                       sets:         [][]string{{apple}},
+                       batches: []batch{
+                               {dictionary: "a", indices: "[0, 1]", wantIDs: 
[]int64{2}},
+                               {dictionary: "b", indices: "[0, 1]", wantIDs: 
[]int64{1}},
+                       },
+               },
+               {
+                       name:         "shorter_dictionary",
+                       dictionaries: map[string]string{"a": `["apple", "bob", 
"cherry", "date"]`, "b": `["bob", "cherry", "apple"]`},
+                       sets:         [][]string{{apple}},
+                       batches: []batch{
+                               {dictionary: "a", indices: "[0, 1]", wantIDs: 
[]int64{2}},
+                               {dictionary: "b", indices: "[0, 2]", wantIDs: 
[]int64{1}},
+                       },
+               },
+               {
+                       name:         "null_index_and_null_entry_with_null_key",
+                       dictionaries: map[string]string{"a": `["apple", null, 
"cherry", "date", "egg"]`},
+                       sets:         [][]string{{null}},
+                       batches:      []batch{{dictionary: "a", indices: "[0, 
null, 1, 2]", wantIDs: []int64{1, 4}}},
+               },
+               {
+                       name:         
"null_index_and_null_entry_without_null_key",
+                       dictionaries: map[string]string{"a": `["apple", null, 
"cherry", "date", "egg"]`},
+                       sets:         [][]string{{apple}},
+                       batches:      []batch{{dictionary: "a", indices: "[0, 
null, 1, 2]", wantIDs: []int64{2, 3, 4}}},
+               },
+               {
+                       name:         "sliced_over_shared_dictionary",
+                       dictionaries: map[string]string{"a": `["apple", "bob", 
"cherry", "date", "egg"]`},
+                       sets:         [][]string{{apple}},
+                       batches: []batch{
+                               {dictionary: "a", indices: "[1, 2, 0, 0, 3, 
1]", offset: 3, wantIDs: []int64{5, 6}},
+                               {dictionary: "a", indices: "[4, 0, 2]", offset: 
1, wantIDs: []int64{3}},
+                       },
+               },
+               {
+                       name:             "sliced_dictionary_values",
+                       dictionaries:     map[string]string{"a": `["zzz", 
"apple", "bob", "cherry", "date"]`},
+                       dictionaryOffset: 1,
+                       sets:             [][]string{{apple}},
+                       batches:          []batch{{dictionary: "a", indices: 
"[0, 1]", wantIDs: []int64{2}}},
+               },
+               {
+                       // The second set's row 1 is already deleted by the 
first set, so
+                       // the second set never looks up apple.
+                       name:         "delete_sets_share_dictionary",
+                       dictionaries: map[string]string{"a": `["apple", "bob", 
"cherry", "date"]`},
+                       sets:         [][]string{{apple}, 
{"\x01\x00\x00\x00\x03bob"}},
+                       batches: []batch{
+                               {dictionary: "a", indices: "[0, 1]", wantIDs: 
nil},
+                               {dictionary: "a", indices: "[1, 0, 2]", 
wantIDs: []int64{3}},
+                       },
+               },
+               {
+                       // The second batch is long enough for the per-batch 
entry bitmap,
+                       // so the third batch must not reuse results from the 
first.
+                       name:         "entry_bitmap_between_batches",
+                       dictionaries: map[string]string{"a": `["apple", "bob", 
"cherry"]`, "b": `["cherry", "bob", "apple"]`},
+                       sets:         [][]string{{apple}},
+                       batches: []batch{
+                               {dictionary: "a", indices: "[0, 1]", wantIDs: 
[]int64{2}},
+                               {dictionary: "b", indices: "[0, 1, 2, 0]", 
wantIDs: []int64{1, 2, 4}},
+                               {dictionary: "b", indices: "[0, 2]", wantIDs: 
[]int64{1}},
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       mem := 
memory.NewCheckedAllocator(memory.DefaultAllocator)
+                       defer mem.AssertSize(t, 0)
+                       ctx := compute.WithAllocator(t.Context(), mem)
+
+                       dictionaries := make(map[string]arrow.Array, 
len(tt.dictionaries))
+                       for name, values := range tt.dictionaries {
+                               full, _, err := array.FromJSON(mem, 
arrow.BinaryTypes.String, strings.NewReader(values))

Review Comment:
   The new across-batch tests use only `arrow.BinaryTypes.String`, so the 
binary and 64-bit-offset memo paths are untested. 
`TestProcessEqualityDeletesDictionary` covers those value types with four 
dictionary entries and five rows, which selects the existing per-batch bitmap 
instead of this memo. Please parameterize the across-batch tests over String, 
LargeString, Binary and LargeBinary, retaining the sliced-dictionary and null 
cases, so those paths are checked against the expected surviving rows.



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