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

SQL: change the default precision for CURRENT_TIMESTAMP #39288

Closed
astefan opened this issue Feb 22, 2019 · 5 comments · Fixed by #39391
Closed

SQL: change the default precision for CURRENT_TIMESTAMP #39288

astefan opened this issue Feb 22, 2019 · 5 comments · Fixed by #39391

Comments

@astefan
Copy link
Contributor

astefan commented Feb 22, 2019

For CURRENT_TIMESTAMP function at the moment we have the following documentation example:

SELECT CURRENT_TIMESTAMP AS result;

         result
------------------------
2018-12-12T14:48:52.448Z

Which isn't entirely correct, because the lack of a precision, defaults it to 0. The 0 precision means no milliseconds are returned.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@matriv
Copy link
Contributor

matriv commented Feb 22, 2019

In my opinion we should change the behaviour, as for example PostgreSQL behaves like:

postgres=# select current_timestamp;
       current_timestamp
-------------------------------
 2019-02-22 10:55:28.484944+02
(1 row)

oracle and sqlserver seems to behave also the same way: https://docs.microsoft.com/en-us/sql/t-sql/functions/current-timestamp-transact-sql?view=sql-server-2017#a-get-the-current-system-date-and-time
http://www.oracletutorial.com/oracle-date-functions/oracle-current_timestamp/

MySQL on the other hand seems to return by default only seconds.

@bpintea
Copy link
Contributor

bpintea commented Feb 22, 2019

I would also favor one of the two solutions: present meaningful millis with precision 3, or stop at seconds with default precision 0.

@costin
Copy link
Member

costin commented Feb 25, 2019

It seems to me that there's no clear rule regarding precision and it's to the operating system/implementation. On one hand I like the default precision (0 in this case) however I can see how, based on the existing behavior, the millis are expected hence why I propose to change, for current_timestamp, the precision to 3.

@astefan astefan added >enhancement and removed >docs General docs changes labels Feb 25, 2019
@astefan astefan changed the title SQL: adjust the documentation to reflect the default precision for CURRENT_TIMESTAMP SQL: change the default precision for CURRENT_TIMESTAMP Feb 25, 2019
@astefan astefan removed the v6.6.2 label Feb 27, 2019
@astefan
Copy link
Contributor Author

astefan commented Feb 27, 2019

master (8.0.0): dbb9331
7.x (7.1.0): 542e2c5
7.0 (7.0.0): 3a84ccc
6.7 (6.7.0): 5dc5c6a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants