-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: interval type not using same comparison as sql equality for aggregation or insertion #79549
Comments
Nice find! I wonder if the explanation of the problem in #57876 is related to this bug. |
This made me think of composite sensitivity:
And now I'm afraid that there's a number of other related bugs:
Example of (2):
|
The problem in (2) above is actually much broader than hash-sharded indexes. It looks like you can get incorrect results with any index on an interval column. On v21.2.7:
|
More examples of different values that should both compare equal and also bucket together:
(Anyone who has seen Rent might be scratching their head at that last one, but this bit from the postgres docs explains it: "Fractional parts of units greater than months are truncated to be an integer number of months, e.g. '1.5 years' becomes '1 year 6 mons'. Fractional parts of weeks and days are computed to be an integer number of days and microseconds, assuming 30 days per month and 24 hours per day, e.g., '1.75 months' becomes 1 mon 22 days 12:00:00.") |
Based on
The improper interval doesn't necessarily have to be stored to get incorrect results, it could simply be used as a constant in a query. For example, this gives incorrect results:
|
A related problem: #80999 |
Another related problem: #81577 |
Manually synced with Jira |
It appears that the
INTERVAL
type is not using the same comparison for SQL equality as for aggregation. These queries illustrate the problem:In PostgreSQL, the two interval values are equal, group together in the same bucket, and count as the same key during insertion. PostgreSQL 14.2:
But in CockroachDB, the two interval values are equal, but do not group together in the same bucket or count as the same key during insertion. CockroachDB v22.1.0-beta.1, same for both vectorized engine and row-based engine:
Jira issue: CRDB-14903
Epic: CRDB-20062
The text was updated successfully, but these errors were encountered: