예제 #1
0
def make_table(project,
               dataset_id,
               table_id,
               friendly_name=None,
               description=None,
               expires=None,
               partitioning_type=None,
               view_use_legacy_sql=None,
               view_query=None,
               schema=None,
               labels=None):
    dataset_ref = DatasetReference(project, dataset_id)
    table_ref = TableReference(dataset_ref, table_id)
    table = Table(table_ref)
    table.friendly_name = friendly_name
    table.description = description
    table.expires = expires
    table.partitioning_type = partitioning_type
    if view_use_legacy_sql is not None:
        table.view_use_legacy_sql = view_use_legacy_sql
    if view_query is not None:
        table.view_query = view_query
    table.schema = schema
    if labels is not None:
        table.labels = labels
    return table
예제 #2
0
    def _create_brand_new_tables(self, product_id):
        """
    Creates new tables in the specified BigQuery dataset

    Args:
      product_id (str):
        A string representing the desired product_id 

    """
        for table_name in self.tables:
            table_ref = self.datasets[product_id]['datasets'].table(table_name)
            table = Table(table_ref, schema=self.schemas[table_name])
            table.partitioning_type = _TABLE_PARTITION_TIME

            self.client.create_table(table)  # API request
            self.datasets[product_id]['tables'][table_name] = (
                self.client.get_table(table_ref))
        return