hexpop.py
def bq_create_table(dataset,
                    table_id,
                    schema=None,
                    partition=None,
                    partition_hourly=False,
                    cluster=None,
                    description=None,
                    force_new=False):
    """Create BigQuery table, forcefully if required."""
    client = bq_client()
    table_id = '.'.join([dataset.project, dataset.dataset_id, table_id])
    if force_new:
        client.delete_table(table_id, not_found_ok=True)  # clean slate
    table = bigquery.Table(table_id, schema=schema)
    if partition:
        table.time_partitioning = bigquery.TimePartitioning()
        table.time_partitioning.field = partition
        if partition_hourly:
            table.time_partitioning.type_ = bigquery.TimePartitioningType.HOUR
        else:
            table.time_partitioning.type_ = bigquery.TimePartitioningType.DAY
    if cluster:
        table.clustering_fields = cluster
    if description:
        table.description = description
    try:
        return client.create_table(table)
    except Conflict:
        return client.get_table(table)
Create BigQuery table, forcefully if required.
Create BigQuery table, forcefully if required.
Create BigQuery table forcefully if required .
def bq_create_table(dataset,
                    table_id,
                    schema=None,
                    partition=None,
                    partition_hourly=False,
                    cluster=None,
                    description=None,
                    force_new=False):
    client = bq_client()
    table_id = '.'.join([dataset.project, dataset.dataset_id, table_id])
    if force_new:
        client.delete_table(table_id, not_found_ok=True)  
    table = bigquery.Table(table_id, schema=schema)
    if partition:
        table.time_partitioning = bigquery.TimePartitioning()
        table.time_partitioning.field = partition
        if partition_hourly:
            table.time_partitioning.type_ = bigquery.TimePartitioningType.HOUR
        else:
            table.time_partitioning.type_ = bigquery.TimePartitioningType.DAY
    if cluster:
        table.clustering_fields = cluster
    if description:
        table.description = description
    try:
        return client.create_table(table)
    except Conflict:
        return client.get_table(table)
def bq_create_table ( dataset , table_id , schema = None , partition = None , partition_hourly = False , cluster = None , description = None , force_new = False ) : client = bq_client ( ) table_id = '.' . join ( [ dataset . project , dataset . dataset_id , table_id ] ) if force_new : client . delete_table ( table_id , not_found_ok = True ) table = bigquery . Table ( table_id , schema = schema ) if partition : table . time_partitioning = bigquery . TimePartitioning ( ) table . time_partitioning . field = partition if partition_hourly : table . time_partitioning . type_ = bigquery . TimePartitioningType . HOUR else : table . time_partitioning . type_ = bigquery . TimePartitioningType . DAY if cluster : table . clustering_fields = cluster if description : table . description = description try : return client . create_table ( table ) except Conflict : return client . get_table ( table )
Create BigQuery table, forcefully if required.
Create BigQuery table forcefully if required .
"""Create BigQuery table, forcefully if required.""" # clean slate
dataset
table_id
schema
partition
partition_hourly
cluster
description
force_new