Skip to content

fix: case expressions type coercion#5796

Closed
korowa wants to merge 1 commit intoapache:mainfrom
korowa:case_return_type
Closed

fix: case expressions type coercion#5796
korowa wants to merge 1 commit intoapache:mainfrom
korowa:case_return_type

Conversation

@korowa
Copy link
Contributor

@korowa korowa commented Mar 30, 2023

Which issue does this PR close?

Closes #5694.

Rationale for this change

While building projection schema (initial planning step), CASE return type calculated as output type of first WHEN ... THEN ... which could potentially cause erroneous type coercions at later planning stages.

What changes are included in this PR?

Output type of CASE expressions, while building projection schema, now considers all THEN-types and ELSE-type (if exists) and uses common get_coerce_type_for_case_when type coercion routine.

Are these changes tested?

Test cases for CASE expression with mixed NULL/NOT NULL THEN/ELSE-types added

Are there any user-facing changes?

No

@github-actions github-actions bot added the logical-expr Logical plan and expressions label Mar 30, 2023
@alamb
Copy link
Contributor

alamb commented Mar 30, 2023

Is this related to #5734 from @mslapek ?

@korowa
Copy link
Contributor Author

korowa commented Mar 31, 2023

My bad, this is a complete duplicate -- should have checked before creating PR.

Good news still, that #5694 can be closed after #5734 is merged.

@korowa korowa closed this Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spurious cast to Uint8 inserted when coalesce is used in a context of a join

2 participants