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

fix: Wrong interval functions for BigQuery #367

Merged
merged 2 commits into from
Feb 13, 2020

Conversation

lvauvillier
Copy link
Contributor

Fix BigQuery error:

Dropping Cache: {
  "cacheKey": [
    "SELECT CASE\n    WHEN CURRENT_TIMESTAMP() < DATETIME_ADD(TIMESTAMP(?), INTERVAL 7 day) THEN FLOOR(UNIX_SECONDS(CURRENT_TIMESTAMP()) / 86400) END",
    [
      "2020-01-12T23:59:59Z"
    ]
  ]
} 
Error: No matching signature for function DATETIME_ADD for argument types: TIMESTAMP, INTERVAL INT64 DATE_TIME_PART. Supported signature: DATETIME_ADD(DATETIME, INTERVAL INT64 DATE_TIME_PART) at [2:32]

@paveltiunov
Copy link
Member

@lvauvillier Thanks for contributing this one! DATETIME here may seem weird but it's correct implementation but probably wrong name right now. Bug is on this line: https://github.com/cube-js/cube.js/blob/c72ab079d53458b7377bc12f498667110af18689/packages/cubejs-schema-compiler/adapter/BaseQuery.js#L1533. So the solution is to introduce addTimestampInterval and subtractTimestampInterval methods which should use addInterval and subtractInterval in base implementation and should be overridden in BigqueryQuery.

@lvauvillier
Copy link
Contributor Author

Thanks @paveltiunov. I have just pushed an update.

@paveltiunov
Copy link
Member

@lvauvillier Looks great! Thanks again!

@paveltiunov paveltiunov merged commit 0e09d4d into cube-js:master Feb 13, 2020
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

Successfully merging this pull request may close these issues.

2 participants