tanmayrauth commented on code in PR #891:
URL: https://github.com/apache/iceberg-go/pull/891#discussion_r3082692518
##########
table/internal/parquet_files.go:
##########
@@ -726,6 +762,65 @@ func (w wrapPqArrowReader) GetRecords(ctx context.Context,
cols []int, tester an
return w.GetRecordReader(ctx, cols, rgList)
}
+// buildFieldIDToColIdx maps each Iceberg field ID to its 0-based column index
in
+// the Parquet file schema. Used to translate bloom filter predicates (which
carry
+// field IDs) into the column positions required by BloomFilterReader.
+func buildFieldIDToColIdx(meta *metadata.FileMetaData) map[int]int {
+ sc := meta.Schema
+ result := make(map[int]int, sc.NumColumns())
+ for i := 0; i < sc.NumColumns(); i++ {
+ fieldID := int(sc.Column(i).SchemaNode().FieldID())
+ result[fieldID] = i
+ }
+
+ return result
+}
+
+// checkRowGroupBloomFilters checks each bloom predicate against the bloom
filter
+// for its column in row group rg. Returns false (skip) if ANY predicate has
none
+// of its values present in the bloom filter. Returns true (keep) on any error
or
+// missing bloom filter data — bloom filters are an optimisation, never a
+// correctness gate.
+func checkRowGroupBloomFilters(
+ bfReader *metadata.BloomFilterReader,
+ rg int,
+ fieldIDToColIdx map[int]int,
+ preds []RowGroupBloomPred,
+) (bool, error) {
+ rgBFReader, err := bfReader.RowGroup(rg)
+ if err != nil || rgBFReader == nil {
+ return true, nil
+ }
Review Comment:
Good catch. Splited the guard: err != nil now returns false, err
(propagated); rgBFReader == nil still returns true, nil since a row group
simply having no bloom filter data is a valid state worth skipping gracefully.
--
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]