Table Args
Creates a table resource in a dataset for Google BigQuery. For more information see the official documentation and API.
Note: On newer versions of the provider, you must explicitly set
deletion_protection=false
(and runpulumi update
to write the field to state) in order to destroy an instance. It is recommended to not set this field (or set it to true) until you're ready to destroy.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const _default = new gcp.bigquery.Dataset("default", {
datasetId: "foo",
friendlyName: "test",
description: "This is a test description",
location: "EU",
defaultTableExpirationMs: 3600000,
labels: {
env: "default",
},
});
const defaultTable = new gcp.bigquery.Table("default", {
datasetId: _default.datasetId,
tableId: "bar",
timePartitioning: {
type: "DAY",
},
labels: {
env: "default",
},
schema: `[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
},
{
"name": "state",
"type": "STRING",
"mode": "NULLABLE",
"description": "State where the head office is located"
}
]
`,
});
const sheet = new gcp.bigquery.Table("sheet", {
datasetId: _default.datasetId,
tableId: "sheet",
externalDataConfiguration: {
autodetect: true,
sourceFormat: "GOOGLE_SHEETS",
googleSheetsOptions: {
skipLeadingRows: 1,
},
sourceUris: ["https://docs.google.com/spreadsheets/d/123456789012345"],
},
});
import pulumi
import pulumi_gcp as gcp
default = gcp.bigquery.Dataset("default",
dataset_id="foo",
friendly_name="test",
description="This is a test description",
location="EU",
default_table_expiration_ms=3600000,
labels={
"env": "default",
})
default_table = gcp.bigquery.Table("default",
dataset_id=default.dataset_id,
table_id="bar",
time_partitioning={
"type": "DAY",
},
labels={
"env": "default",
},
schema="""[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
},
{
"name": "state",
"type": "STRING",
"mode": "NULLABLE",
"description": "State where the head office is located"
}
]
""")
sheet = gcp.bigquery.Table("sheet",
dataset_id=default.dataset_id,
table_id="sheet",
external_data_configuration={
"autodetect": True,
"source_format": "GOOGLE_SHEETS",
"google_sheets_options": {
"skip_leading_rows": 1,
},
"source_uris": ["https://docs.google.com/spreadsheets/d/123456789012345"],
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var @default = new Gcp.BigQuery.Dataset("default", new()
{
DatasetId = "foo",
FriendlyName = "test",
Description = "This is a test description",
Location = "EU",
DefaultTableExpirationMs = 3600000,
Labels =
{
{ "env", "default" },
},
});
var defaultTable = new Gcp.BigQuery.Table("default", new()
{
DatasetId = @default.DatasetId,
TableId = "bar",
TimePartitioning = new Gcp.BigQuery.Inputs.TableTimePartitioningArgs
{
Type = "DAY",
},
Labels =
{
{ "env", "default" },
},
Schema = @"[
{
""name"": ""permalink"",
""type"": ""STRING"",
""mode"": ""NULLABLE"",
""description"": ""The Permalink""
},
{
""name"": ""state"",
""type"": ""STRING"",
""mode"": ""NULLABLE"",
""description"": ""State where the head office is located""
}
]
",
});
var sheet = new Gcp.BigQuery.Table("sheet", new()
{
DatasetId = @default.DatasetId,
TableId = "sheet",
ExternalDataConfiguration = new Gcp.BigQuery.Inputs.TableExternalDataConfigurationArgs
{
Autodetect = true,
SourceFormat = "GOOGLE_SHEETS",
GoogleSheetsOptions = new Gcp.BigQuery.Inputs.TableExternalDataConfigurationGoogleSheetsOptionsArgs
{
SkipLeadingRows = 1,
},
SourceUris = new[]
{
"https://docs.google.com/spreadsheets/d/123456789012345",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/bigquery"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := bigquery.NewDataset(ctx, "default", &bigquery.DatasetArgs{
DatasetId: pulumi.String("foo"),
FriendlyName: pulumi.String("test"),
Description: pulumi.String("This is a test description"),
Location: pulumi.String("EU"),
DefaultTableExpirationMs: pulumi.Int(3600000),
Labels: pulumi.StringMap{
"env": pulumi.String("default"),
},
})
if err != nil {
return err
}
_, err = bigquery.NewTable(ctx, "default", &bigquery.TableArgs{
DatasetId: _default.DatasetId,
TableId: pulumi.String("bar"),
TimePartitioning: &bigquery.TableTimePartitioningArgs{
Type: pulumi.String("DAY"),
},
Labels: pulumi.StringMap{
"env": pulumi.String("default"),
},
Schema: pulumi.String(`[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
},
{
"name": "state",
"type": "STRING",
"mode": "NULLABLE",
"description": "State where the head office is located"
}
]
`),
})
if err != nil {
return err
}
_, err = bigquery.NewTable(ctx, "sheet", &bigquery.TableArgs{
DatasetId: _default.DatasetId,
TableId: pulumi.String("sheet"),
ExternalDataConfiguration: &bigquery.TableExternalDataConfigurationArgs{
Autodetect: pulumi.Bool(true),
SourceFormat: pulumi.String("GOOGLE_SHEETS"),
GoogleSheetsOptions: &bigquery.TableExternalDataConfigurationGoogleSheetsOptionsArgs{
SkipLeadingRows: pulumi.Int(1),
},
SourceUris: pulumi.StringArray{
pulumi.String("https://docs.google.com/spreadsheets/d/123456789012345"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigquery.Dataset;
import com.pulumi.gcp.bigquery.DatasetArgs;
import com.pulumi.gcp.bigquery.Table;
import com.pulumi.gcp.bigquery.TableArgs;
import com.pulumi.gcp.bigquery.inputs.TableTimePartitioningArgs;
import com.pulumi.gcp.bigquery.inputs.TableExternalDataConfigurationArgs;
import com.pulumi.gcp.bigquery.inputs.TableExternalDataConfigurationGoogleSheetsOptionsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var default_ = new Dataset("default", DatasetArgs.builder()
.datasetId("foo")
.friendlyName("test")
.description("This is a test description")
.location("EU")
.defaultTableExpirationMs(3600000)
.labels(Map.of("env", "default"))
.build());
var defaultTable = new Table("defaultTable", TableArgs.builder()
.datasetId(default_.datasetId())
.tableId("bar")
.timePartitioning(TableTimePartitioningArgs.builder()
.type("DAY")
.build())
.labels(Map.of("env", "default"))
.schema("""
[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
},
{
"name": "state",
"type": "STRING",
"mode": "NULLABLE",
"description": "State where the head office is located"
}
]
""")
.build());
var sheet = new Table("sheet", TableArgs.builder()
.datasetId(default_.datasetId())
.tableId("sheet")
.externalDataConfiguration(TableExternalDataConfigurationArgs.builder()
.autodetect(true)
.sourceFormat("GOOGLE_SHEETS")
.googleSheetsOptions(TableExternalDataConfigurationGoogleSheetsOptionsArgs.builder()
.skipLeadingRows(1)
.build())
.sourceUris("https://docs.google.com/spreadsheets/d/123456789012345")
.build())
.build());
}
}
resources:
default:
type: gcp:bigquery:Dataset
properties:
datasetId: foo
friendlyName: test
description: This is a test description
location: EU
defaultTableExpirationMs: 3.6e+06
labels:
env: default
defaultTable:
type: gcp:bigquery:Table
name: default
properties:
datasetId: ${default.datasetId}
tableId: bar
timePartitioning:
type: DAY
labels:
env: default
schema: |
[
{
"name": "permalink",
"type": "STRING",
"mode": "NULLABLE",
"description": "The Permalink"
},
{
"name": "state",
"type": "STRING",
"mode": "NULLABLE",
"description": "State where the head office is located"
}
]
sheet:
type: gcp:bigquery:Table
properties:
datasetId: ${default.datasetId}
tableId: sheet
externalDataConfiguration:
autodetect: true
sourceFormat: GOOGLE_SHEETS
googleSheetsOptions:
skipLeadingRows: 1
sourceUris:
- https://docs.google.com/spreadsheets/d/123456789012345
Import
BigQuery tables can be imported using any of these accepted formats:
projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}
{{project}}/{{dataset_id}}/{{table_id}}
{{dataset_id}}/{{table_id}}
When using thepulumi import
command, BigQuery tables can be imported using one of the formats above. For example:
$ pulumi import gcp:bigquery/table:Table default projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}
$ pulumi import gcp:bigquery/table:Table default {{project}}/{{dataset_id}}/{{table_id}}
$ pulumi import gcp:bigquery/table:Table default {{dataset_id}}/{{table_id}}
Constructors
Properties
Specifies the configuration of a BigLake managed table. Structure is documented below
Specifies column names to use for data clustering. Up to four top-level columns are allowed, and should be specified in descending priority order.
Whether or not to allow the provider to destroy the instance. Unless this field is set to false in state, a =destroy
or =update
that would delete the instance will fail.
The field description.
Specifies how the table should be encrypted. If left blank, the table will be encrypted with a Google-managed key; that process is transparent to the user. Structure is documented below.
The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed.
Options defining open source compatible table. Structure is documented below.
Describes the data format, location, and other properties of a table stored outside of BigQuery. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. Structure is documented below.
A descriptive name for the table.
If specified, configures this table as a materialized view. Structure is documented below.
The maximum staleness of data that could be returned when the table (or stale MV) is queried. Staleness encoded as a string encoding of [SQL IntervalValue
If specified, configures range-based partitioning for this table. Structure is documented below.
If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified.
The tags attached to this table. Tag keys are globally unique. Tag key is expected to be in the namespaced format, for example "123456789012/environment" where 123456789012 is the ID of the parent organization or project resource for this tag key. Tag value is expected to be the short name, for example "Production". See Tag definitions for more details.
Specifies metadata of the foreign data type definition in field schema. Structure is documented below.
Defines the primary key and foreign keys. Structure is documented below.
View sets the optional parameter "view": Specifies the view that determines which table information is returned. By default, basic table information and storage statistics (STORAGE_STATS) are returned. Possible values: TABLE_METADATA_VIEW_UNSPECIFIED, BASIC, STORAGE_STATS, FULL
Replication info of a table created using "AS REPLICA" DDL like: CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv
. Structure is documented below.
If specified, configures time-based partitioning for this table. Structure is documented below.
If specified, configures this table as a view. Structure is documented below.