hexpop.py
def bq_prep_dataset(dataset_name, list_tables=False, test_dataset=False):
    """Check that BigQuery project and dataset are ready."""
    logger = logging.getLogger(f"{__name__}.{sys._getframe().f_code.co_name}")
    initialize_logging(logger)
    client = bq_client()
    logger.info("bq project %s ready", client.project)
    if test_dataset:
        dataset_name += '_test'
    dataset_id = f'{client.project}.{dataset_name}'
    try:
        dataset = client.get_dataset(dataset_id)
    except NotFound:
        logger.warning("bq dataset %s not found, creating", dataset_id)
        dataset = bigquery.Dataset(dataset_id)
        dataset.location = 'US'
        dataset = client.create_dataset(dataset)
    logger.info("bq dataset %s ready", dataset.full_dataset_id)
    if list_tables:
        return dataset, [
            t.table_id for t in client.list_tables(dataset_id)
            if t.table_type == 'TABLE'
        ]
    return dataset
Check that BigQuery project and dataset are ready.
Check that BigQuery project and dataset are ready.
Check that BigQuery project and dataset are ready .
def bq_prep_dataset(dataset_name, list_tables=False, test_dataset=False):
    logger = logging.getLogger(f"{__name__}.{sys._getframe().f_code.co_name}")
    initialize_logging(logger)
    client = bq_client()
    logger.info("bq project %s ready", client.project)
    if test_dataset:
        dataset_name += '_test'
    dataset_id = f'{client.project}.{dataset_name}'
    try:
        dataset = client.get_dataset(dataset_id)
    except NotFound:
        logger.warning("bq dataset %s not found, creating", dataset_id)
        dataset = bigquery.Dataset(dataset_id)
        dataset.location = 'US'
        dataset = client.create_dataset(dataset)
    logger.info("bq dataset %s ready", dataset.full_dataset_id)
    if list_tables:
        return dataset, [
            t.table_id for t in client.list_tables(dataset_id)
            if t.table_type == 'TABLE'
        ]
    return dataset
def bq_prep_dataset ( dataset_name , list_tables = False , test_dataset = False ) : logger = logging . getLogger ( f"{__name__}.{sys._getframe().f_code.co_name}" ) initialize_logging ( logger ) client = bq_client ( ) logger . info ( "bq project %s ready" , client . project ) if test_dataset : dataset_name += '_test' dataset_id = f'{client.project}.{dataset_name}' try : dataset = client . get_dataset ( dataset_id ) except NotFound : logger . warning ( "bq dataset %s not found, creating" , dataset_id ) dataset = bigquery . Dataset ( dataset_id ) dataset . location = 'US' dataset = client . create_dataset ( dataset ) logger . info ( "bq dataset %s ready" , dataset . full_dataset_id ) if list_tables : return dataset , [ t . table_id for t in client . list_tables ( dataset_id ) if t . table_type == 'TABLE' ] return dataset
Check that BigQuery project and dataset are ready.
Check that BigQuery project and dataset are ready .
"""Check that BigQuery project and dataset are ready."""
dataset_name
list_tables
test_dataset