#!/usr/bin/env python

## Create a schema for the table and then create the table.

from google.cloud import bigquery

client = bigquery.Client()

table_id = "innate-entry-286804.rns_sample_dataset.rns_db_4"

schema=[
    bigquery.SchemaField('itemid','STRING',mode='REQUIRED'),
    bigquery.SchemaField('quantity','STRING',mode='REQUIRED'),
    bigquery.SchemaField('userid','STRING',mode='REQUIRED'),
    bigquery.SchemaField('Metadata','RECORD',mode='REPEATED',fields=[
                                                                bigquery.SchemaField('geography','STRING',mode='REQUIRED'),
                                                                bigquery.SchemaField('location','STRING',mode='REQUIRED'),
                                                                bigquery.SchemaField('hourofday','INT64',mode='REQUIRED')
                                                            ]
    )
]

table = bigquery.Table(table_id,schema=schema)
## Creating an ingestion-time partitioned table
table.time_partitioning = bigquery.TimePartitioning("HOUR") ## Defaults to DAY
table = client.create_table(table)
print("Created table {}.{}.{}".format(table.project, table.dataset_id, table.table_id))

83f8c193a287a07e096a190df7736b4c103aeaa4
<mask token>

<mask token>
print('Created table {}.{}.{}'.format(table.project, table.dataset_id,
    table.table_id))

<mask token>
client = bigquery.Client()
table_id = 'innate-entry-286804.rns_sample_dataset.rns_db_4'
schema = [bigquery.SchemaField('itemid', 'STRING', mode='REQUIRED'),
    bigquery.SchemaField('quantity', 'STRING', mode='REQUIRED'), bigquery.
    SchemaField('userid', 'STRING', mode='REQUIRED'), bigquery.SchemaField(
    'Metadata', 'RECORD', mode='REPEATED', fields=[bigquery.SchemaField(
    'geography', 'STRING', mode='REQUIRED'), bigquery.SchemaField(
    'location', 'STRING', mode='REQUIRED'), bigquery.SchemaField(
    'hourofday', 'INT64', mode='REQUIRED')])]
table = bigquery.Table(table_id, schema=schema)
table.time_partitioning = bigquery.TimePartitioning('HOUR')
table = client.create_table(table)
print('Created table {}.{}.{}'.format(table.project, table.dataset_id,
    table.table_id))

from google.cloud import bigquery
client = bigquery.Client()
table_id = 'innate-entry-286804.rns_sample_dataset.rns_db_4'
schema = [bigquery.SchemaField('itemid', 'STRING', mode='REQUIRED'),
    bigquery.SchemaField('quantity', 'STRING', mode='REQUIRED'), bigquery.
    SchemaField('userid', 'STRING', mode='REQUIRED'), bigquery.SchemaField(
    'Metadata', 'RECORD', mode='REPEATED', fields=[bigquery.SchemaField(
    'geography', 'STRING', mode='REQUIRED'), bigquery.SchemaField(
    'location', 'STRING', mode='REQUIRED'), bigquery.SchemaField(
    'hourofday', 'INT64', mode='REQUIRED')])]
table = bigquery.Table(table_id, schema=schema)
table.time_partitioning = bigquery.TimePartitioning('HOUR')
table = client.create_table(table)
print('Created table {}.{}.{}'.format(table.project, table.dataset_id,
    table.table_id))

#!/usr/bin/env python

## Create a schema for the table and then create the table.

from google.cloud import bigquery

client = bigquery.Client()

table_id = "innate-entry-286804.rns_sample_dataset.rns_db_4"

schema=[
    bigquery.SchemaField('itemid','STRING',mode='REQUIRED'),
    bigquery.SchemaField('quantity','STRING',mode='REQUIRED'),
    bigquery.SchemaField('userid','STRING',mode='REQUIRED'),
    bigquery.SchemaField('Metadata','RECORD',mode='REPEATED',fields=[
                                                                bigquery.SchemaField('geography','STRING',mode='REQUIRED'),
                                                                bigquery.SchemaField('location','STRING',mode='REQUIRED'),
                                                                bigquery.SchemaField('hourofday','INT64',mode='REQUIRED')
                                                            ]
    )
]

table = bigquery.Table(table_id,schema=schema)
## Creating an ingestion-time partitioned table
table.time_partitioning = bigquery.TimePartitioning("HOUR") ## Defaults to DAY
table = client.create_table(table)
print("Created table {}.{}.{}".format(table.project, table.dataset_id, table.table_id))
