perf: Update CaseToCoalesceRule to ignore irrelevant casts.#18400
perf: Update CaseToCoalesceRule to ignore irrelevant casts.#18400gianm wants to merge 2 commits intoapache:masterfrom
Conversation
Previously, CaseToCoalesceRule ignored nullability casts when deciding
if "x" and "y" in "CASE WHEN x IS NOT NULL THEN y" match and could
therefore form the basis of a COALESCE. This was too strict, since it
considered a cast from VARCHAR to VARCHAR(2000), which can happen after
applying JSON_VALUE, to be relevant. It is not relevant, because it does
not affect how we execute the query.
This patch updates the logic to ignore nullability casts and also casts
that change irrelevant properties of the type. ("Irrelevant" being defined
as "properties that do not affect how the query executes".)
|
This pull request has been marked as stale due to 60 days of inactivity. |
|
This pull request has been marked as stale due to 60 days of inactivity. |
|
This pull request has been marked as stale due to 60 days of inactivity. |
Previously, CaseToCoalesceRule ignored nullability casts when deciding if "x" and "y" in "CASE WHEN x IS NOT NULL THEN y" match and could therefore form the basis of a COALESCE. This was too strict, since it considered a cast from VARCHAR to VARCHAR(2000), which can happen after applying JSON_VALUE, to be relevant. It is not relevant, because it does not affect how we execute the query.
This patch updates the logic to ignore nullability casts and also casts that change irrelevant properties of the type. ("Irrelevant" being defined as "properties that do not affect how the query executes".)
This change speeds up queries, because generally
COALESCEruns faster thanCASE. Note that one of the test cases is now vectorizable, where it wasn't previously. The new tests are also both vectorizable.