Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve case expr constant handling for when <scalar> #14159

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jan 16, 2025

Draft as it builds on #14156

Which issue does this PR close?

Rationale for this change

While reviewing #14156 I noticed that the code unecessairly expanded a constant to an array, and that I could update it avoid having any internal errors

What changes are included in this PR?

  1. New .slt tests
  2. Update case handling code to make it clear the errors are unreachable

Are these changes tested?

yes, with new slt tests

Are there any user-facing changes?

}
}
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not actually possible as the previous version of the code expands out a constant to an array

                ColumnarValue::Array(when_expr_value.into_array(batch.num_rows())?)

ColumnarValue::Scalar(_) => {
ColumnarValue::Array(when_expr_value.into_array(batch.num_rows())?)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line has the effect of creating an array out of a scalar -- I remove that and added the special case handling for the values

@alamb alamb marked this pull request as ready for review January 18, 2025 17:13
@alamb alamb changed the title Improve case expr constant handling Improve case expr constant handling for when <scalar> Jan 18, 2025
@Omega359
Copy link
Contributor

LGTM

Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@jayzhan211 jayzhan211 merged commit 0a85bb4 into apache:main Jan 20, 2025
26 of 27 checks passed
@jayzhan211
Copy link
Contributor

Thanks @alamb @Omega359

@alamb alamb deleted the alamb/slt_test branch January 20, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants