Skip to content

fix: preserve Utf8View return type in lpad#20659

Open
Tim-53 wants to merge 3 commits intoapache:mainfrom
Tim-53:lpad_utf8view
Open

fix: preserve Utf8View return type in lpad#20659
Tim-53 wants to merge 3 commits intoapache:mainfrom
Tim-53:lpad_utf8view

Conversation

@Tim-53
Copy link
Contributor

@Tim-53 Tim-53 commented Mar 3, 2026

Which issue does this PR close?

Part of #20585

Rationale for this change

lpad was returning Utf8 when given Utf8View inputs, causing unnecessary type casting downstream

What changes are included in this PR?

  • Fix return_type to preserve Utf8View when the input is Utf8View
  • Introduce StringArrayWriter trait in unicode/common.rs to abstract over GenericStringBuilder
    and StringViewBuilder, allowing lpad to produce the correct output type
  • Add tests covering Utf8View return type and value correctness in string_view.slt

Are these changes tested?

Yes new unit tests were added to cover all input/fill combinations.
Slt tests were added to verify the return type is preserved for Utf8View inputs

Are there any user-facing changes?

lpad now correctly returns Utf8View when given Utf8View input.

Note: rpad has the same issue and will be addressed in a follow-up.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Mar 3, 2026
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.

1 participant