ryukobayashi opened a new pull request, #6915: URL: https://github.com/apache/hive/pull/6915
### What changes were proposed in this pull request? This pull request fixes NULL handling and predicate evaluation in Iceberg copy-on-write MERGE rewrites. The rewrite now: - Uses target file-path presence and an explicit source-row marker to distinguish matched, target-only, and source-only rows. - Parenthesizes ON and WHEN predicates consistently. - Uses `IS NOT TRUE` when excluding rows handled by an earlier `WHEN MATCHED` clause. - Removes the CoW retained-row predicate that conflated NULL join keys with source-only rows. - Reuses a filtered matched CTE for marker and per-file matched-row-count generation. - Preserves the affected-row-count behavior introduced by HIVE-30064. - Avoids source-presence alias collisions and protects generated SQL from trailing line comments. - Updates the affected CoW MERGE qtest expected outputs. ### Why are the changes needed? The previous CoW MERGE rewrite used nullable target join keys to identify source-only rows. As a result, target rows with NULL join keys could be misclassified, lost during file rewrites, or produce spurious rows. The rewrite also assembled ON and WHEN predicates as raw SQL fragments. This could change `AND` / `OR` precedence and incorrectly handle SQL `UNKNOWN` results. In some cases, the CoW rewrite could generate invalid NULL-path rewrite candidates or produce results different from native MERGE. ### Does this PR introduce _any_ user-facing change? Yes. CoW MERGE now follows native MERGE semantics for: - Target rows with NULL join keys. - NULL-safe join predicates. - `UNKNOWN` results in `WHEN MATCHED` predicates. - Parenthesized `AND` / `OR` expressions. - Source-only row detection. Queries that previously produced incorrect results may now preserve, update, delete, or insert rows differently according to the expected MERGE semantics. ### How was this patch tested? Regression coverage was added for: - NULL join keys. - NULL-safe joins. - `UNKNOWN` predicates. - `AND` / `OR` predicate grouping. - Source-presence marker collisions. -- 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]
