Add partition support to BigQuery#2058
Conversation
gcloud/bigquery/table.py
Outdated
| """ | ||
| partitioned = None | ||
| if "timePartitioning" in self._properties: | ||
| partitioned = self._properties.get('timePartitioning').get('type') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
The docs for creating partitioned tables point to a query for listing partitions, Could we use that to implement `table.list_partitions'? |
| with self.assertRaises(ValueError): | ||
| table.partitioning_type = "HASH" | ||
| with self.assertRaises(ValueError): | ||
| table.partition_expiration = "NEVER" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Thank you for the patch! |
|
I've got a method I didn't include for list_partitions that does generate and run that query. What I'm not sure about is the best way to fake a partitioned table for testing said method. |
Assuming the method looks something like: def list_partitions(self):
query = self._client.query(
'SELECT partition_id from [%s.%s$__PARTITIONS_SUMMARY__]' %
(self.dataset_name, self.name))
query.run()
return [row[0] for row in query.rows]I think I would just mock up the |
This adds the ability to create a partitioned table. It would be nice to expose a table.list_partitions() method, but currently there is not an API-based way of returning partitions. So, for now, it simply allows users to interact with the current partitioning API.