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

[cloud/v3] Casting BIGINT to TIMESTAMP doesn't seem to work anymore #24581

Closed
Notilarie opened this issue Jan 18, 2024 · 7 comments
Closed

[cloud/v3] Casting BIGINT to TIMESTAMP doesn't seem to work anymore #24581

Notilarie opened this issue Jan 18, 2024 · 7 comments
Assignees
Labels

Comments

@Notilarie
Copy link

Steps to reproduce:
List the minimal actions needed to reproduce the behaviour.

  1. Open data explore on InfluxDB Cloud
  2. Execute the folowing query: SELECT 1705590600000000000::TIMESTAMP

Expected behaviour:
I would expect a timestamp

Actual behaviour:
An exception is thrown:
Error while planning query: Optimizer rule 'simplify_expressions' failed
caused by
Arrow error: Compute error: Overflow happened on: 1705590600000000000 * 1000000000: rpc error: code = InvalidArgument desc = Error while planning query: Optimizer rule 'simplify_expressions' failed
caused by
Arrow error: Compute error: Overflow happened on: 1705590600000000000 * 1000000000

Environment info:

  • InfluxDB Cloud

As workaround I use the following query:
SELECT 1705590600000000000::BIGINT UNSIGNED::TIMESTAMP

On older versions of InfluxDB, unsigned big ints are not allowed to cast to timestamp

@philjb
Copy link
Contributor

philjb commented Feb 6, 2024

@btasker - this is reported as a issue in cloud serverless.

@philjb philjb added the area/c2 label Feb 6, 2024
@philjb philjb changed the title Casting BIGINT to TIMESTAMP doesn't seem to work anymore [cloud/c2] Casting BIGINT to TIMESTAMP doesn't seem to work anymore Feb 6, 2024
@btasker
Copy link

btasker commented Feb 6, 2024

This looks like a SQL issue (it's being run via the Cloud UI which doesn't accept InfluxQL) so doesn't fall under my purview.

I've flagged up internally.

@helenosheaa
Copy link
Member

The Cloud UI does accept InfluxQL as well these days but anyway I think the problem is probably coming from InfluxQL-IOx, when direct casting an integer using ::timestamp IOx will default to treat it as seconds (we will work on fixing this)

@NotiArie Workaround in the meantime would be to use to_timestamp_seconds or to_timestamp_mills etc to explicitly specify the precision to use.

@philjb philjb added v3 and removed area/c2 labels Feb 12, 2024
@philjb philjb changed the title [cloud/c2] Casting BIGINT to TIMESTAMP doesn't seem to work anymore [cloud/v3] Casting BIGINT to TIMESTAMP doesn't seem to work anymore Feb 12, 2024
@jeffreyssmith2nd jeffreyssmith2nd removed their assignment Feb 20, 2024
@mhilton
Copy link
Contributor

mhilton commented Feb 21, 2024

This was changed in datafusion (the query engine used by influxdb v3) in November. The stated intention being to make timestamp conversions behave consistently, and be consistent with the same queries run in postgresql.

If you need subsecond accuracy for your timestamps then the functions to_timestamp_millis, to_timestamp_micros, or to_timestamp_nanos can be used to perform explicit conversions.

@Notilarie
Copy link
Author

Thanks,
Both functions to_timestamp and to_timestamp_nanos work fine and are returning the timestamp with nanoseconds precision.

BTW, funny thing is that SELECT 1705590600000000000::BIGINT UNSIGNED::TIMESTAMP does work even with negative numbers.

@mhilton
Copy link
Contributor

mhilton commented Feb 21, 2024

BTW, funny thing is that SELECT 1705590600000000000::BIGINT UNSIGNED::TIMESTAMP does work even with negative numbers.

Thanks for letting us know, I'd avoid using that just because it feels like something that might be fixed in the future.

@helenosheaa
Copy link
Member

thanks for the report, as theres a workaround and this was a change in Datafusion closing this as there's no further action needed

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

No branches or pull requests

6 participants