Skip to content

Conversation

@hagino3000
Copy link
Contributor

Table has expirationTime option.
https://cloud.google.com/bigquery/docs/reference/v2/tables

So I added expiration_time option to create_table method.

Usage

>>> now = datetime.utcnow()
>>> now.strftime('%Y-%m-%d %H:%M:%S')
'2015-07-21 06:21:33'
>>> a_day_after = int(time.mktime(now.timetuple()))*1000 + 1000*60*60*24 # After 1 day
>>> a_day_after
1437513693000
>>> client = bigquery.get_client(...)
>>> client.create_table('test', 'expiry_test2', {}, expiration_time=a_day_after)
True
>>> client.get_table('test', 'expiry_test2')['expirationTime']
u'1437513693000'

Also we can check expiration time of table using bq command.

`--> bq show test.expiry_test2
Table vg-zucks-zgok:test.expiry_test2

   Last modified    Schema   Total Rows   Total Bytes     Expiration
 ----------------- -------- ------------ ------------- -----------------
  21 Jul 15:21:46            0            0             22 Jul 06:21:33

@hagino3000 hagino3000 changed the title [WIP]Add expiration_time option for create_table Add expiration_time option for create_table Jul 21, 2015
@hagino3000
Copy link
Contributor Author

Also I run make unit on master branch, it failed as same as travis result.
But I cannot find what is wrong.

@tylertreat
Copy link
Owner

Thanks, I will investigate the issue with the unit tests.

@tylertreat
Copy link
Owner

@hagino3000 I made a PR into your branch with a fix for the unit tests (hagino3000#1). Once you merge that, I will merge this PR.

Takashi Nishibayashi and others added 2 commits July 22, 2015 10:30
@hagino3000
Copy link
Contributor Author

Thanks I merged your PR.

tylertreat added a commit that referenced this pull request Jul 22, 2015
Add expiration_time option for create_table
@tylertreat tylertreat merged commit 0f5a1df into tylertreat:master Jul 22, 2015
@hagino3000 hagino3000 deleted the add_table_expiration_time branch July 23, 2015 01:01
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.

3 participants