Skip to content

[fix] Add type coercion from NULL to Interval to make date_bin more p…#89

Merged
LiaCastaneda merged 1 commit intobranch-52from
lia/bring-date-bin-fix
Mar 3, 2026
Merged

[fix] Add type coercion from NULL to Interval to make date_bin more p…#89
LiaCastaneda merged 1 commit intobranch-52from
lia/bring-date-bin-fix

Conversation

@LiaCastaneda
Copy link

Cherry picks apache#20499 (This made it to the v53 release)

…ostgres compatible (apache#20499)

## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

- Closes apache#20502

## Rationale for this change

The following query is failing with the following error:

`SELECT date_bin(NULL, TIMESTAMP '2023-01-01 12:30:00', TIMESTAMP
'2023-01-01 12:00:00')
`

`Error: Error during planning: Failed to coerce arguments to satisfy a
call to 'date_bin' function: coercion from Null, Timestamp(ns),
Timestamp(ns) to the signature OneOf([....])`

## What changes are included in this PR?

Fix `date_bin(NULL, ...)` to return `NULL` instead of a planning error
by allowing Nulls to coerce to Interva.

## Are these changes tested?

I added a sqllogictest case to verify the query executes and returns
`NULL`.

## Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

Yes, previously `date_bin(NULL, ...) `returned a planning error. It now
returns NULL.

(cherry picked from commit e937cad)
@LiaCastaneda LiaCastaneda marked this pull request as ready for review March 3, 2026 12:03
@LiaCastaneda LiaCastaneda merged commit 2bca186 into branch-52 Mar 3, 2026
59 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants