shihchengwei-lab commented on PR #2729:
URL: https://github.com/apache/iceberg-go/pull/2729#issuecomment-7235193123

   `partitionBounds` can make `IS NULL` silently skip a file that contains NULL 
rows.
   
   Parquet min/max bounds describe only non-null values. For a file containing 
`NULL` and `7`, the footer can therefore report `min=max=7` together with a 
nonzero null count. This change moves those bounds into `partitionBounds` and 
records the file as partition `amount=7`; manifest pruning then skips the 
entire file for `amount IS NULL`.
   
   On `74f174da9077b3fa232d9f2467f742fe4305b9c4`, both `none` and `counts` 
return 2 rows without a filter but 0 rows for `amount IS NULL`; the correct 
filtered result is 1. The existing `7/7` test still passes.
   
   The same case on base `911ada48be09f7856f100692b042899109b2fdfe` returns 2 
filtered rows—also incorrect, but it does not omit the real NULL row. This PR 
changes that false positive into a silent false negative.
   
   <details>
   <summary>Minimal reproduction</summary>
   
   Add beside `TestPartitionInferenceWithoutBoundMetrics`:
   
   ```go
   func TestPartitionInferenceWithoutBoundMetricsKeepsNullRowsVisible(t 
*testing.T) {
       value := int32(7)
       schema := iceberg.NewSchema(0,
           iceberg.NestedField{
               ID: 1, Name: "amount",
               Type: iceberg.PrimitiveTypes.Int32,
           })
       spec := iceberg.NewPartitionSpecID(0,
           iceberg.PartitionField{
               SourceIDs: []int{1},
               FieldID:   1000,
               Name:      "amount",
               Transform: iceberg.IdentityTransform{},
           })
   
       for _, mode := range []string{"none", "counts"} {
           t.Run(mode, func(t *testing.T) {
               ctx := t.Context()
               path := writePartialMetricsParquet(
                   t, schema, [][]*int32{{nil}, {&value}}, "")
   
               cat, err := hadoop.NewCatalog(
                   ctx, "local", t.TempDir(), nil)
               require.NoError(t, err)
               t.Cleanup(func() { require.NoError(t, cat.Close()) })
               require.NoError(t, cat.CreateNamespace(
                   ctx, catalog.ToIdentifier("db"), nil))
   
               tbl, err := cat.CreateTable(
                   ctx,
                   catalog.ToIdentifier("db", "amounts"),
                   schema,
                   catalog.WithPartitionSpec(&spec),
                   catalog.WithProperties(iceberg.Properties{
                       table.MetricsModeColumnConfPrefix + ".amount": mode,
                   }))
               require.NoError(t, err)
   
               txn := tbl.NewTransaction()
               require.NoError(t, txn.AddDataFilesByPath(
                   ctx, []string{path}, nil, false))
               tbl, err = txn.Commit(ctx)
               require.NoError(t, err)
   
               files, err := tbl.Scan().PlanFiles(ctx)
               require.NoError(t, err)
               require.Len(t, files, 1)
               assert.Equal(t,
                   map[int]any{1000: value},
                   files[0].File.Partition())
   
               allRows, err := tbl.Scan().ToArrowTable(ctx)
               require.NoError(t, err)
               assert.EqualValues(t, 2, allRows.NumRows())
               allRows.Release()
   
               nullRows, err := tbl.Scan(table.WithRowFilter(
                   iceberg.IsNull(iceberg.Reference("amount")),
               )).ToArrowTable(ctx)
               require.NoError(t, err)
               assert.EqualValues(t, 1, nullRows.NumRows())
               nullRows.Release()
           })
       }
   }
   ```
   
   Run:
   
   ```sh
   go test ./table \
     -run '^TestPartitionInferenceWithoutBoundMetricsKeepsNullRowsVisible$' \
     -count=1 -v
   ```
   
   Both modes fail with `expected: 1, actual: 0`.
   
   </details>
   
   Could partition inference reject a file when complete null counts prove that 
an inferred partition source contains both null and non-null values, and add 
this case as a regression test?
   
   AI assisted with the code review, reproduction design, and wording. I ran 
the focused test against both commits with Go 1.26.3 on Linux.


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