riverandeye commented on code in PR #2768:
URL: https://github.com/apache/iceberg-go/pull/2768#discussion_r4747588045


##########
table/evaluators_test.go:
##########
@@ -3305,6 +3305,82 @@ func (suite *StrictMetricsTestSuite) TestNotInMetrics() {
        }
 }
 
+func (suite *StrictMetricsTestSuite) TestStartsWithAndNotStartsWith() {
+       stringFile := func(lower, upper string) iceberg.DataFile {
+               return &mockDataFile{
+                       path:        "string_file.parquet",
+                       format:      iceberg.ParquetFile,
+                       count:       50,
+                       filesize:    3,
+                       valueCounts: map[int]int64{3: 50},
+                       nullCounts:  map[int]int64{3: 0},
+                       lowerBounds: map[int][]byte{3: []byte(lower)},
+                       upperBounds: map[int][]byte{3: []byte(upper)},
+               }
+       }
+       abcToAbd, aaToDC := stringFile("abc", "abd"), stringFile("aa", "dC")
+       bbbOnly := &mockDataFile{
+               path:        "bbb_file.parquet",
+               format:      iceberg.ParquetFile,
+               count:       50,
+               filesize:    3,
+               valueCounts: map[int]int64{5: 50},
+               nullCounts:  map[int]int64{5: 10},
+               lowerBounds: map[int][]byte{5: []byte("bbb")},
+               upperBounds: map[int][]byte{5: []byte("bbb")},
+       }
+
+       required, allNulls, someNulls := iceberg.Reference("required"), 
iceberg.Reference("all_nulls"), iceberg.Reference("some_nulls")
+
+       tests := []struct {
+               expr     iceberg.BooleanExpression
+               file     iceberg.DataFile
+               expected bool
+               msg      string
+       }{
+               {iceberg.StartsWith(required, "ab"), abcToAbd, true, "should 
match: both bounds start with the prefix"},
+               {iceberg.StartsWith(required, "a"), abcToAbd, true, "should 
match: both bounds start with the single char prefix"},
+               {iceberg.StartsWith(required, ""), abcToAbd, true, "should 
match: all strings start with empty prefix"},
+               {iceberg.StartsWith(required, "abc"), abcToAbd, false, "should 
not match: upper bound does not start with the prefix"},
+               {iceberg.StartsWith(required, "zzz"), abcToAbd, false, "should 
not match: no bounds start with the prefix"},
+               {iceberg.StartsWith(required, "abcdef"), abcToAbd, false, 
"should not match: prefix is longer than the bounds"},
+               {iceberg.StartsWith(required, "a"), aaToDC, false, "should not 
match: upper bound does not start with the prefix"},
+               {iceberg.StartsWith(required, "e"), aaToDC, false, "should not 
match: no bounds start with the prefix"},
+               {iceberg.StartsWith(required, "a"), suite.dataFiles[0], false, 
"should not match: no bounds available for column"},
+               {iceberg.StartsWith(allNulls, "a"), suite.dataFiles[0], false, 
"should not match: all null values do not satisfy startsWith"},
+               {iceberg.StartsWith(someNulls, "b"), suite.dataFiles[1], false, 
"should not match: some nulls means not all rows can satisfy startsWith"},

Review Comment:
   Thanks @badalprasadsingh and @zeroshade! Added both rows in 2883e1d:
   - `StartsWith(some_nulls, "b")` on a file whose bounds are both `"bbb"` with 
10 nulls, so only the null check can return false.
   - `StartsWith(required, "ab")` on a file with bounds `"aa"`..`"ab"`, so only 
the lower-bound check can return false.
   
   Each row fails when its check is removed.
   



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