badalprasadsingh commented on code in PR #2768:
URL: https://github.com/apache/iceberg-go/pull/2768#discussion_r4743943466
##########
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:
the lower-bound check or the null check is left uncovered, this one passes
because "eee" doesn't start with "b", not because of the nulls
without the lower-bound check, `Delete` would drop rows that don't match, so
IMO, we can add a row for each
--
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]