kalyan4uonly
kalyan4uonly

Reputation: 335

How to Use decorators in STANDARD SQL

I want to recover the truncated data from a table in bigquery an hour back, I found one of the solution in legacy SQL like below:

SELECT COUNT(*) FROM [PROJECT_ID:DATASET.TABLE@-3600000]

How to achieve the same in standard sql.

Thanks

Upvotes: 1

Views: 567

Answers (2)

Tanveer Uddin
Tanveer Uddin

Reputation: 1525

Relative time decorator is not supported in standard sql yet. You can use absolute timestamp as the decorator in standard sql. Link from official Bigquery here.

EDIT

As per Elliott's response, its supported now in standard sql with different syntax.

Upvotes: 1

Elliott Brossard
Elliott Brossard

Reputation: 33705

See the FOR SYSTEM TIME AS OF documentation. You would want something like this:

SELECT *
FROM `project`.dataset.table FOR SYSTEM TIME AS OF
  TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)

Upvotes: 2

Related Questions