Skip to content

Conversation

@petern48
Copy link
Contributor

@petern48 petern48 commented Sep 9, 2025

Which issue does this PR close?

Rationale for this change

See issue.

What changes are included in this PR?

Add support for null argument to to_local_time function

Are these changes tested?

Added both scalar and array tests

Are there any user-facing changes?

Yes

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Sep 9, 2025
Comment on lines 362 to 364
match time_value {
Timestamp(timeunit, _) => Ok(Timestamp(*timeunit, None)),
DataType::Null => Ok(Timestamp(Nanosecond, 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'm following the same behavior as date_trunc.rs here: returning a Nanosecond Timestamp datatype for nulls.

fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
match &arg_types[1] {
Timestamp(Nanosecond, None) | Utf8 | DataType::Date32 | Null => {
Ok(Timestamp(Nanosecond, None))
}

@petern48 petern48 marked this pull request as ready for review September 9, 2025 15:59
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

😍 🏃

Thank you so much @petern48

@alamb
Copy link
Contributor

alamb commented Sep 9, 2025

FYI @2010YOUY01

because to_local_time impls coerce_types, the Null argument gets coerced
@findepi findepi merged commit bfc5067 into apache:main Sep 12, 2025
28 checks passed
@findepi
Copy link
Member

findepi commented Sep 12, 2025

Merged, thanks!

@petern48 petern48 deleted the to_local_time_null branch September 12, 2025 15:24
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.

Incorrect null literal handling for to_local_time() function (SQLancer)

3 participants