siva_0223
siva_0223

Reputation: 21

Execute DDL to create tables in BigQuery using Pulumi

I'm using Pulumi as Automation tool to create table/view in BigQuery . Unfortunately Pulumi supports only JSON schema instead I need to create table/view from DDL.

sample ddl :

create table <table_name> ( col1 datatype , .....) partition by date_col ;

Tried Pulumi jobs to create table but that's also not working

job = gcp.bigquery.Job("job",
                       job_id="job_query",
                       labels={
                           "example-label": "example-value",
                       },
                       query=gcp.bigquery.JobQueryArgs(
                           query="""
                           CREATE TABLE `pulumi_test.tb_test` (
                                      `id` string(36) ,
                                      `date_col` DATE
                                    )PARTITION BY date_col
                                    OPTIONS(
                                      require_partition_filter=true
                                    )
                                    """,
                           use_legacy_sql = False,

                       ))

Upvotes: 1

Views: 389

Answers (1)

siva_0223
siva_0223

Reputation: 21

Pulumi has command interface which can be used to resolve this issue . We can use Pulumi interface and can leverage on BigQuery command lines ("bq")

import pulumi
from pulumi_command import local
random = local.Command("random",create=" bq query --use_legacy_sql=false < 
                      test.sql" )   
pulumi.export("random", random.stdout)

Upvotes: 1

Related Questions