Skip to content

Comments

fix: Avoid unnecessary type casts in concat_ws#20436

Open
neilconway wants to merge 3 commits intoapache:mainfrom
neilconway:neilc/concat-ws-type-fixes
Open

fix: Avoid unnecessary type casts in concat_ws#20436
neilconway wants to merge 3 commits intoapache:mainfrom
neilconway:neilc/concat-ws-type-fixes

Conversation

@neilconway
Copy link
Contributor

@neilconway neilconway commented Feb 19, 2026

Which issue does this PR close?

Rationale for this change

  1. concat_ws returned Utf8, regardless of the input types it was called with. If it was called with LargeUtf8, returning Utf8 might overflow. In general, functions like these should operate on all three string representations unless there is a compelling reason not to (e.g., this is how concat works).
  2. simplify_concat_ws always constructed new literals with type Utf8. This lead to unnecessary casts when its inputs were of a different string type.

What changes are included in this PR?

  • Support concat_ws return type matching its input types, following how concat does it.
  • In simplify_concat_ws, construct literals with the right type, not always Utf8
  • Refactor return_type for concat to be more readable
  • Make StringViewArrayBuilder API more similar to the other string array builders, WRT null handling
  • Add new unit and SLT tests
  • Update test output for changed types

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes: some queries involving concat_ws will now omit unnecessary cast operations, and the return type of concat_ws might be any of the three string types. Generally these changes should match user expectations better than the previous behavior.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Feb 19, 2026
@Omega359
Copy link
Contributor

I did a quick look at the changes and nothing obvious jumped out at me. I'll try and find time to do a more extensive review if no one else beats me to it.

@neilconway
Copy link
Contributor Author

@Omega359 Thank you!

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

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

concat_ws does unnecessary type casts

2 participants