<jupyter_start><jupyter_text>The BiggerQuery tutorial part 2 What you will lean in part 2* Automatically generating a Airflow DAG from workflow.* Deploying DAG.  Your workflowLets clean up notebook from part 1.<jupyter_code>import biggerquery as bgq
PROJECT_ID = ''  # put you own project ID
dataset = bgq.Dataset(
    project_id=PROJECT_ID,
    dataset_name='transaction_aggregates',
    internal_tables=['user_transaction_metrics'],
    external_tables={
        'transactions': '{}.transactions.transactions'.format(PROJECT_ID)
    })
create_user_transaction_metrics_table = dataset.create_table('''
CREATE TABLE IF NOT EXISTS user_transaction_metrics (
    user_id STRING,
    metric_name STRING,
    metric_value STRING,
    
    partition_timestamp TIMESTAMP)
PARTITION BY DATE(partition_timestamp)
''')
write_truncate_user_transaction_value = dataset.write_truncate('user_transaction_metrics', 
'''
SELECT 
    TIMESTAMP('{dt}') as partition_timestamp,
    user_id,
    CAST(sum(CAST(transaction_value as FLOAT64)) as string) as metric_value,
    'USER_TRANSACTION_VALUE' as metric_name
FROM `{transactions}`
WHERE DATE(partition_timestamp) = '{dt}'
GROUP BY user_id
''')
write_append_user_transaction_count = dataset.write_append('user_transaction_metrics', 
'''
SELECT 
    TIMESTAMP('{dt}') as partition_timestamp,
    user_id,
    CAST(count(*) as string) as metric_value,
    'USER_TRANSACTION_COUNT' as metric_name
FROM `{transactions}`
WHERE DATE(partition_timestamp) = '{dt}'
GROUP BY user_id
''')
workflow = bgq.Workflow(definition=[
    create_user_transaction_metrics_table.to_job(),
    write_truncate_user_transaction_value.to_job(),
    write_append_user_transaction_count.to_job()])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09573241061130335, 'fraction_numerical': 0.0028835063437139563, 'mean_word_length': 5.995967741935484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '664523', 'license': 'Apache-2.0', 'n_tokens_mistral': 557, 'n_tokens_neox': 541, 'n_words': 118, 'path': 'biggerquery_tutorial/part2.ipynb', 'repo_name': 'MarcinMoskala/biggerquery', 'size': '1734'}