Skip to content

Conversation

@Jefffrey
Copy link
Contributor

Which issue does this PR close?

N/A

Rationale for this change

Clean up some signatures & unnecessary code in string functions

What changes are included in this PR?

Various refactors, see comments.

Are these changes tested?

Existing tests.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the functions Changes to functions implementation label Dec 19, 2025
if arg_types[0] == DataType::Utf8View {
Ok(DataType::Utf8View)
} else {
utf8_to_str_type(&arg_types[0], "ltrim")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

utf8_to_str_type() preserves type to LargeUtf8 if input is large, otherwise just Utf8; we can see we also preserve view type, so in this case we are just preserving the input type as is

TypeSignature::Exact(vec![LargeUtf8, Utf8, Int64]),
TypeSignature::Exact(vec![Utf8, LargeUtf8, Int64]),
TypeSignature::Exact(vec![LargeUtf8, LargeUtf8, Int64]),
Coercion::new_exact(TypeSignatureClass::Native(logical_string())),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More compact API

UInt16 => make_scalar_function(to_hex::<UInt16Type>, vec![])(&args.args),
Int8 => make_scalar_function(to_hex::<Int8Type>, vec![])(&args.args),
UInt8 => make_scalar_function(to_hex::<UInt8Type>, vec![])(&args.args),
DataType::Null => Ok(ColumnarValue::Scalar(ScalarValue::Utf8(None))),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer having the DataType:: but this is just personal preference, can revert if is too verbose

@Jefffrey Jefffrey marked this pull request as ready for review December 19, 2025 08:33
Copy link
Member

@martin-g martin-g left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Dec 29, 2025
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.

2 participants