Skip to content

feat: support binary types in octet_length - #24867

Open
eddietejeda wants to merge 1 commit into
apache:mainfrom
eddietejeda:feat/octet-length-binary
Open

feat: support binary types in octet_length#24867
eddietejeda wants to merge 1 commit into
apache:mainfrom
eddietejeda:feat/octet-length-binary

Conversation

@eddietejeda

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

octet_length should count the raw bytes of binary data without expensive encoding workaround.

What changes are included in this PR?

  • Adds support for Binary, LargeBinary, and BinaryView.
  • Returns Int64 for LargeBinary and Int32 for the other types.
  • Updates the error message to say “strings or binary.”

What is the testing strategy for this PR?

Unit and SQL logic tests cover binary arrays and scalars, non-UTF-8 data, nulls, dictionary encoding, and return types.

Are there any user-facing changes?

Yes. octet_length now counts the raw bytes of binary values. Existing string behavior is unchanged.

octet_length now accepts Binary, LargeBinary, and BinaryView. The
signature uses the same shape as md5 and digest. LargeBinary returns
Int64. The other two return Int32.

No coercion to Utf8 runs. Thus the function counts the raw bytes of
non-UTF-8 input.

Also reword the message in get_optimal_return_type! to "strings or
binary".
@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Sep 2, 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.

octet_length should accept binary types

1 participant