Ejemplo n.º 1
0
def up(client):
    client = BigQueryMigration(client)
    dataset = client.dataset(dataset_name)

    table = client.client.get_table(dataset.table(table_name))
    orig_schema = table.schema
    new_schema = orig_schema.copy()

    new_schema.insert(
        1,
        bigquery.SchemaField('commission_user_id', 'INTEGER', mode='REQUIRED'))

    client.delete_table(table)
    client.create_table(
        name=table_name,
        project=client.client.project,
        schema=new_schema,
        dataset=dataset,
        clustering_fields=['leo_eid:STRING', 'ingestion_timestamp:TIMESTAMP'],
        partition={
            'type': 'range',
            'field': 'client_partition_id',
            'start': 1,
            'end': 100,
            'interval': 1
        })
    return dataset
Ejemplo n.º 2
0
def down(client):
    client = BigQueryMigration(client)
    dataset = client.dataset(dataset_name)

    table = client.client.get_table(dataset.table(table_name))
    orig_schema = table.schema
    new_schema = orig_schema.copy()

    if new_schema[1].name == 'commission_user_id':
        new_schema.pop(1)
        client.delete_table(table)
        client.create_table(name=table_name,
                            project=client.client.project,
                            schema=new_schema,
                            dataset=dataset,
                            partition={
                                'type': 'range',
                                'field': 'client_partition_id',
                                'start': 1,
                                'end': 100,
                                'interval': 1
                            },
                            clustering_fields=[
                                'leo_eid:STRING',
                                'ingestion_timestamp:TIMESTAMP'
                            ])

    return dataset
Ejemplo n.º 3
0
def up(client):
    migration = BigQueryMigration(client)
    dataset = migration.dataset(dataset_name)

    table = migration.client.get_table(dataset.table(table_name))
    orig_schema = table.schema
    new_schema = orig_schema.copy()

    del new_schema[1]
    new_schema.insert(
        0, bigquery.SchemaField('dag_id', 'STRING', mode='REQUIRED'))

    migration.delete_table(table)
    migration.create_table(name=table_name,
                           project=migration.client.project,
                           schema=new_schema,
                           dataset=dataset)
    return dataset
Ejemplo n.º 4
0
def down(client):
    migration = BigQueryMigration(client)
    dataset = migration.dataset(dataset_name)

    table = migration.client.get_table(dataset.table(table_name))
    orig_schema = table.schema
    new_schema = orig_schema.copy()

    if new_schema[0].name == 'dag_id':
        new_schema.pop(0)

        new_schema.insert(
            1, bigquery.SchemaField('leo_eid', 'STRING', mode="NULLABLE"))

        migration.delete_table(table)
        migration.create_table(name=table_name,
                               project=migration.client.project,
                               schema=new_schema,
                               dataset=dataset)

    return dataset
def down(client):
    client = BigQueryMigration(client)
    dataset = client.dataset(dataset_name)
    table = client.client.get_table(dataset.table(table_name))
    client.delete_table(table)
Ejemplo n.º 6
0
def down(client):
    migration = BigQueryMigration(client)
    dataset = migration.dataset(dataset_name)
    table = migration.client.get_table(dataset.table(table_name))
    migration.delete_table(table)