Skip to content

HIVE-28911: Improve SEARCH expansion to exploit <> operator#6503

Open
rubenada wants to merge 5 commits into
apache:masterfrom
rubenada:HIVE-28911
Open

HIVE-28911: Improve SEARCH expansion to exploit <> operator#6503
rubenada wants to merge 5 commits into
apache:masterfrom
rubenada:HIVE-28911

Conversation

@rubenada
Copy link
Copy Markdown
Contributor

@rubenada rubenada commented May 21, 2026

What changes were proposed in this pull request?

Improve SEARCH expansion to exploit <> operator.
SEARCH operator can be used to represent many types of range predicates including the inequality operator (<>).
For example d_dom <> 10 can be represented as SEARCH($9, Sarg[(-∞..10), (10..+∞)]); or cases like d_dom <> 10 and d_dom <> 20 can be represented as SEARCH($9, Sarg[(-∞..10), (10..20), (20..+∞)]).
Currently, after SEARCH expansion the following expression will be generated: OR(<($9, 10), >($9, 10))in the first case, OR(<($9, 10), >($9, 20), AND(>($9, 10), <($9, 20))) in the second case. With the proposed change we shall get the simpler <>($9, 10) in case of one value, or NOT (IN ($9, 10, 20)) in case of multiple values.

Why are the changes needed?

Exploit the inequality operator when expanding ranges to generate simpler and slightly more efficient expressions.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Unit test added. A few test plans adjusted reflecting this change.

…d of 'ref <> value1 AND ref <> value2' since the latter can break statistic propagation on partitioned tables (such as Iceberg).

During Conjunctive Normal Form (CNF) expansion, nested inequalities inside 'OR' clauses flatten into structures that Hive's SearchArgument (Sarg) builder and Iceberg's partition-pruning layer cannot natively translate. This may cause the compiler to abandon filter pushdown at the TableScan phase, resetting column statistics from PARTIAL to NONE.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants