Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9863 - avoid moving constants for DATE - DATE subtractions #9874

Merged
merged 2 commits into from Dec 3, 2023

Conversation

Mytherin
Copy link
Collaborator

@Mytherin Mytherin commented Dec 2, 2023

Fixes #9863

The issue here is that the MoveConstants optimizer assumes that an arithmetic operation returns the same type as the type of its inputs (i.e. INT32 - INT32 = INT32). This is true for (integer) numbers but is not correct for dates - DATE - DATE returns BIGINT (i.e. INT32 - INT32 = INT64). This broken assumption then causes an invalid plan to be generated that leads to a comparison between an INT32 and an INT64, which causes strange behavior.

@Mytherin Mytherin merged commit 1326799 into duckdb:main Dec 3, 2023
42 of 43 checks passed
@Mytherin Mytherin deleted the issue9863 branch December 4, 2023 11:44
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent query results
2 participants