Skip to content

Fix improper expression aliasing during pushdown#13758

Merged
martint merged 1 commit intotrinodb:masterfrom
martint:ppd-improper-aliasing
Aug 22, 2022
Merged

Fix improper expression aliasing during pushdown#13758
martint merged 1 commit intotrinodb:masterfrom
martint:ppd-improper-aliasing

Conversation

@martint
Copy link
Copy Markdown
Member

@martint martint commented Aug 19, 2022

EqualityInference was considering an expression of the form
cast(null AS ...) as an inference candidate, even though it
doens't satisfy the condition of not returning nulls on null
input.

As a result, unrelated expressions were being incorrectly equated
to each other. In particular, for the example in the test,
CAST(null AS varchar) was being considered equivalent to VARCHAR 'hello'
and then substituted in the expression:

CAST(CAST(null AS varchar) AS bigint)

to produce the (invalid) expression:

CAST(VARCHAR 'hello' AS bigint)

Fixes #13565

Documentation

(x) No documentation is needed.

Release notes

(x) Release notes entries required with the following suggested text:

# General
* Fix failure potential failure for queries involving joins and implicit or explicit casts of `null` to a concrete type. ({issue}`13565`)

@cla-bot cla-bot bot added the cla-signed label Aug 19, 2022
@martint martint force-pushed the ppd-improper-aliasing branch from 07da400 to d5b2318 Compare August 20, 2022 01:02
EqualityInference was considering an expression of the form
cast(null AS ...) as an inference candidate, even though it
doens't satisfy the condition of not returning nulls on null
input.

As a result, unrelated expressions were being incorrectly equated
to each other. In particular, for the example in the test,
CAST(null AS varchar) was being considered equivalent to VARCHAR 'hello'
and then substituted in the expression:

    CAST(CAST(null AS varchar) AS bigint)

to produce the (invalid) expression:

    CAST(VARCHAR 'hello' AS bigint)
@martint martint force-pushed the ppd-improper-aliasing branch from d5b2318 to cca5373 Compare August 20, 2022 03:04
@martint martint merged commit 5374ba7 into trinodb:master Aug 22, 2022
@github-actions github-actions bot added this to the 394 milestone Aug 22, 2022
@martint martint deleted the ppd-improper-aliasing branch August 22, 2022 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Predicate push down bug

2 participants