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

bug: the timestamp display with microseconds is not correct. #508

Open
TCeason opened this issue Nov 24, 2024 · 0 comments
Open

bug: the timestamp display with microseconds is not correct. #508

TCeason opened this issue Nov 24, 2024 · 0 comments

Comments

@TCeason
Copy link
Collaborator

TCeason commented Nov 24, 2024

Can reproduce in pr databendlabs/databend#16924

Use bendsql client:

:) select MICROSECONDS_TO_TIMESTAMP(-7233803000000+1), MICROSECONDS_TO_TIMESTAMP(-7233803000000), MICROSECONDS_TO_TIMESTAMP(-7233803000000-1);

SELECT
    MICROSECONDS_TO_TIMESTAMP(((- 7233803000000) + 1)),
    MICROSECONDS_TO_TIMESTAMP((- 7233803000000)),
    MICROSECONDS_TO_TIMESTAMP(((- 7233803000000) - 1))

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ microseconds_to_timestamp(- 7233803000000 + 1) │ microseconds_to_timestamp(- 7233803000000) │ microseconds_to_timestamp(- 7233803000000 - 1) │
│                    Timestamp                   │                  Timestamp                 │                    Timestamp                   │
├────────────────────────────────────────────────┼────────────────────────────────────────────┼────────────────────────────────────────────────┤
│ 1970-01-01 00:00:00                            │ 1969-10-09 06:36:37                        │ 1970-01-01 00:00:00                            │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
1 row read in 0.019 sec. Processed 1 row, 1B (52.63 rows/s, 52B/s)

Use MySQL client or HTTP is ok:

MySQL [(none)]> select MICROSECONDS_TO_TIMESTAMP(-7233803000000+1), MICROSECONDS_TO_TIMESTAMP(-7233803000000), MICROSECONDS_TO_TIMESTAMP(-7233803000000-1);
+------------------------------------------------+--------------------------------------------+------------------------------------------------+
| microseconds_to_timestamp(- 7233803000000 + 1) | microseconds_to_timestamp(- 7233803000000) | microseconds_to_timestamp(- 7233803000000 - 1) |
+------------------------------------------------+--------------------------------------------+------------------------------------------------+
| 1969-10-09 06:36:37.000001                     | 1969-10-09 06:36:37.000000                 | 1969-10-09 06:36:36.999999                     |
+------------------------------------------------+--------------------------------------------+------------------------------------------------+
1 row in set (0.048 sec)

➜  databend git:(to_ts) ✗ curl -uroot: --request POST '0.0.0.0:8000/v1/query/' --header 'Content-Type: application/json' --data-raw '{"sql": "select MICROSECONDS_TO_TIMESTAMP(-7233803000000+1), MICROSECONDS_TO_TIMESTAMP(-7233803000000), MICROSECONDS_TO_TIMESTAMP(-7233803000000-1)"}'
{"id":"965f90a6-01a5-4641-b8cc-93cef7dd0e37","session_id":"66bfefa1-fcfe-444f-9b47-4b0ab6467257","node_id":"ochLt3cou6DsByZpE4fbs4","state":"Succeeded","session":{"database":"default","role":"account_admin","settings":{},"txn_state":"AutoCommit","need_sticky":false,"need_keep_alive":false,"last_server_info":{"id":"ochLt3cou6DsByZpE4fbs4","start_time":"2024-11-24T17:10:20.490+08:00"},"last_query_ids":["965f90a6-01a5-4641-b8cc-93cef7dd0e37"]},"error":null,"warnings":[],"has_result_set":true,"schema":[{"name":"microseconds_to_timestamp(- 7233803000000 + 1)","type":"Timestamp"},{"name":"microseconds_to_timestamp(- 7233803000000)","type":"Timestamp"},{"name":"microseconds_to_timestamp(- 7233803000000 - 1)","type":"Timestamp"}],"data":[["1969-10-09 06:36:37.000001","1969-10-09 06:36:37.000000","1969-10-09 06:36:36.999999"]],"affect":null,"stats":{"scan_progress":{"rows":1,"bytes":1},"write_progress":{"rows":0,"bytes":0},"result_progress":{"rows":1,"bytes":24},"total_scan":{"rows":1,"bytes":1},"running_time_ms":40},"stats_uri":"/v1/query/965f90a6-01a5-4641-b8cc-93cef7dd0e37","final_uri":"/v1/query/965f90a6-01a5-4641-b8cc-93cef7dd0e37/final","next_uri":"/v1/query/965f90a6-01a5-4641-b8cc-93cef7dd0e37/final","kill_uri":"/v1/query/965f90a6-01a5-4641-b8cc-93cef7dd0e37/kill"}%  
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

No branches or pull requests

1 participant