-
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/sem/tree: parse ISO8601 format with decimal places for interval types #59720
Comments
Looks like https://github.com/senseyeio/duration/blob/7c2a214ada46/duration.go#L31 is a reasonable (and MIT license) reference we could use. just a simple regex. (we should reimplement ourselves since there's no need to add a dependency for something so small) |
hi @keithdoggett @rafiss |
@shikamaru404 welcome! thank you for your interest! please go ahead and try it out. when you submit a PR, please add @otan and me as reviewers. |
hi @rafiss |
@shikamaru404 seems like you're right :) |
60570: sql/sem/tree: parse ISO8601 format with decimal places for interval types r=otan a=shikamaru404 Previously, CockroachDB can not parse ISO8601 format interval type with decimals, but Postgres can parse successfully. For example, running "SELECT INTERVAL 'P1Y2M3DT4H5M6.235S'" in CockroachDB will cause an error like: ERROR: could not parse "P1Y2M3DT4H5M6.235S" as type interval: interval: unknown unit . in ISO-8601 duration P1Y2M3DT4H5M6.235S This patch fixes this issue. Now cockroachDB can parse ISO8601 format using decimals correctly and return the same result as Postgres. Fixes: #59720 Release note: none Co-authored-by: shikamaru <jpchen78@foxmail.com>
…ypes Previously, CockroachDB can not parse ISO8601 format interval type with decimals, but Postgres can parse successfully. For example, running "SELECT INTERVAL 'P1Y2M3DT4H5M6.235S'" in CockroachDB will cause an error like: ERROR: could not parse "P1Y2M3DT4H5M6.235S" as type interval: interval: unknown unit . in ISO-8601 duration P1Y2M3DT4H5M6.235S This patch fixes this issue. Now cockroachDB can parse ISO8601 format using decimals correctly and return the same result as Postgres. Fixes: cockroachdb#59720 Release note: none
We do not parse
SELECT INTERVAL 'P1Y2M3DT4H5M6.235S';
correctly on CockroachDB, but this successfully parses in Postgres:Changes should be made in
cockroach/pkg/sql/sem/tree/interval.go
Line 188 in 3699ce6
With unit tests added here:
cockroach/pkg/sql/sem/tree/interval_test.go
Line 46 in 3699ce6
Original:
There are two errors coming from the
PostgresqlIntervalTest
(test/cases/adapters/postgesql/interval_test.rb
) in ActiveRecord.Running
SELECT INTERVAL 'P1Y2M3DT4H5M6.235S';
in a SQL shell gives the following response:This indicates that using a decimal for seconds is causing the error.
The text was updated successfully, but these errors were encountered: