Skip to content

[pull] main from apache:main - #278

Merged
pull[bot] merged 1 commit into
buraksenn:mainfrom
apache:main
Jun 14, 2026
Merged

pull[bot] merged 1 commit into
buraksenn:mainfrom
apache:main

Conversation

@pull

@pull pull Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

## 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 #123` indicates that this PR will close issue #123.
-->

- Closes #22896.

## Rationale for this change

`TRY_CAST` should return NULL on cast failure, but overflowing
date/timestamp casts returned errors.

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

## What changes are included in this PR?
  
- Make scalar temporal overflow checks respect CastOptions.safe.
- Skip DataFusion’s array pre-check for safe casts so Arrow can return
NULLs.
- Add regression tests.

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

## Are these changes tested?

Yes:

```bash
cargo test -p datafusion-common timestamp_overflow_returns
cargo test -p datafusion-expr-common timestamp_array_to_timestamp_overflow
cargo test --test sqllogictests -- datetime/timestamps.slt
```

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

## Are there any user-facing changes?

Yes. TRY_CAST for overflowing date/timestamp casts now returns NULL;
regular CAST still errors.

<!--
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.
-->

## Known Limitation

This PR does not add Date array-path coverage yet. For example:

```sql
SELECT TRY_CAST(d AS TIMESTAMP(9))
FROM (VALUES (DATE '3000-01-01')) t(d);
```

This depends on the upstream Arrow fix in apache/arrow-rs#9825. Once
DataFusion updates to an Arrow version containing that fix, we can add
this regression test.
@pull pull Bot locked and limited conversation to collaborators Jun 14, 2026
@pull pull Bot added the ⤵️ pull label Jun 14, 2026
@pull
pull Bot merged commit cb2542c into buraksenn:main Jun 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant