adiranjan25 opened a new pull request, #19098:
URL: https://github.com/apache/iceberg/pull/19098

   ## Summary
   
   Fixes #19087
   
   This PR fixes a Flink SQL filter pushdown issue where comparisons between 
FLOAT/DOUBLE columns and DECIMAL literals can fail during Iceberg predicate 
binding.
   
   For example:
   
   ```sql
   SELECT id, score
   FROM t_double
   WHERE score <= 14.3;
   ```
   
   Flink represents the DECIMAL literal as `java.math.BigDecimal`. When this 
value is pushed into an Iceberg predicate against a DOUBLE column, predicate 
binding can throw:
   
   ```text
   ValidationException: Invalid value for conversion to type double: 14.3 
(java.math.BigDecimal)
   ```
   
   ## Root Cause
   
   `FlinkFilters.convertFieldAndLiteral()` converts Flink DECIMAL literals into 
`BigDecimal` values without checking whether the target Iceberg column supports 
that literal type.
   
   This can create incompatible Iceberg predicates that fail during manifest 
evaluation.
   
   ## Solution
   
   This PR introduces a conservative correctness fix:
   
   - Detect `BigDecimal` literals compared against FLOAT or DOUBLE fields.
   - Decline unsafe predicate pushdown by returning `Optional.empty()`.
   - Handle both field–literal and literal–field comparison directions.
   - Preserve valid DECIMAL-column predicate pushdown.
   - Apply the fix consistently across Flink 1.20, 2.2, and 2.3.
   
   The affected predicates remain available for evaluation by Flink rather than 
being pushed into Iceberg.
   
   ## Regression Tests
   
   Added tests covering:
   
   - FLOAT and DOUBLE comparisons with DECIMAL literals.
   - Both comparison directions.
   - Mixed predicates containing supported and unsupported filters.
   - Existing DECIMAL-column predicate compatibility.
   - End-to-end Flink 2.3 SQL execution against a nonempty Iceberg table.
   
   The SQL integration test verifies that `WHERE score <= 14.3` executes 
successfully and returns the expected rows.
   
   ## Validation
   
   - Flink 1.20 `TestFlinkFilters` — Passed
   - Flink 2.2 `TestFlinkFilters` — Passed
   - Flink 2.3 `TestFlinkFilters` — Passed
   - Flink 2.3 SQL integration regression test — Passed
   - Spotless Java checks across all three versions — Passed
   - Git whitespace validation — Passed
   
   ## Design Consideration
   
   This approach prioritizes correctness over filter pushdown for mixed 
DECIMAL/floating-point comparisons.
   
   It avoids potentially unsafe numeric coercion and preserves SQL evaluation 
through Flink. Maintainer feedback on the approach is welcome.


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