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

Sub-second EXTRACT behaves differently from postgres #40683

Closed
habnabit opened this issue Sep 11, 2019 · 1 comment · Fixed by #41069
Closed

Sub-second EXTRACT behaves differently from postgres #40683

habnabit opened this issue Sep 11, 2019 · 1 comment · Fixed by #41069
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-investigation Further steps needed to qualify. C-label will change. E-easy Easy issue to tackle, requires little or no CockroachDB experience good first issue

Comments

@habnabit
Copy link

On postgres v11.5 (but I'm pretty sure this has always behaved as such):

=# select current_timestamp, extract(microseconds from current_timestamp);
       current_timestamp       | date_part
-------------------------------+-----------
 2019-09-11 18:03:45.553972+00 |  45553972

On cockroachdb v19.1.3:

> select current_timestamp, extract(microseconds from current_timestamp);
         current_timestamp         | extract
+----------------------------------+---------+
  2019-09-11 18:03:35.056128+00:00 |   56128

The postgres documentation for datetime functions agrees with the postgres behavior: sub-second EXTRACT gives the full seconds as part of the extracted value. "Note that this includes full seconds."

I have to say I prefer the cockroachdb behavior, but it should probably be aligned with the postgres behavior.

@habnabit
Copy link
Author

Oh, I should mention.. I discovered this because also extract(epoch ..) is a float with sub-second precision on postgres but an integer on cockroachdb.

@awoods187 awoods187 added the C-investigation Further steps needed to qualify. C-label will change. label Sep 11, 2019
@awoods187 awoods187 added the A-sql-pgcompat Semantic compatibility with PostgreSQL label Sep 11, 2019
@jordanlewis jordanlewis added E-easy Easy issue to tackle, requires little or no CockroachDB experience good first issue labels Sep 19, 2019
@craig craig bot closed this as completed in 134f535 Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-investigation Further steps needed to qualify. C-label will change. E-easy Easy issue to tackle, requires little or no CockroachDB experience good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants