Galet
Galet

Reputation: 6269

How to set/update expiration time for a table in Google big Query using ruby

I am using google-cloud-bigquery gem for my Ruby on Rails application. I am able to execute the query on the dataset and do the following

  1. Execute query
  2. Create destination table and store results into it
  3. Store the final results into a file from a destination table

Now I want to set the expiration time for the destination table. I find a document to updating a table. But I am unable to find a way to set the expiration time using Ruby language?

Also I am able to fetch expires_at value from a table which returns nil. I don't find a way to set it.

Kindly help

Upvotes: 0

Views: 1905

Answers (1)

Graham Polley
Graham Polley

Reputation: 14781

I'm no Ruby expert, but I also cannot find anything in the docs/api that allows you to set the expiration on a table. You can do it at the dataset level (here) or for partitions on the table (here). It looks like it's not exposed via the client library for some reason.

Another way of doing it is via DDL in SQL e.g:

ALTER TABLE mydataset.mytable
 SET OPTIONS (
   expiration_timestamp=TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 7 DAY),
   description="Table that expires seven days from now"
 )

Upvotes: 3

Related Questions