Handle edge case for date_trunc optimization#19628
Merged
lnkuiper merged 1 commit intoduckdb:mainfrom Nov 7, 2025
Merged
Conversation
When date_trunc(p, t) = t, then we must ensure that the optimized expression uses < instead of <=.
hawkfish
approved these changes
Nov 6, 2025
github-actions bot
pushed a commit
to duckdb/duckdb-r
that referenced
this pull request
Nov 7, 2025
fix checkpointing on files that dont exist (duckdb/duckdb#19344) Handle edge case for date_trunc optimization (duckdb/duckdb#19628)
github-actions bot
added a commit
to duckdb/duckdb-r
that referenced
this pull request
Nov 7, 2025
fix checkpointing on files that dont exist (duckdb/duckdb#19344) Handle edge case for date_trunc optimization (duckdb/duckdb#19628) Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
This was referenced Nov 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a bugfix for the date_trunc optimization pass in #18457. @colinmarc and @drin discovered a particular edge case that got overlooked.
The issue is that when we have
date_trunc(part, t) <= const_rhs, this must be rewritten toinstead of
You can cause this bug to happen in the current code if you use some
tsuch thatdate_trunc(part, t) = t.This should have been noticed because the same edge case handling is already implemented for the
>=case, but I overlooked it. Anyway, it is an easy enough fix.