Table

class Table : KotlinCustomResource

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 run pulumi 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

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 defaultDataset = new Dataset("defaultDataset", 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(defaultDataset.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(defaultDataset.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());
}
}

Import

BigQuery tables imported using any of these accepted formats

$ 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}}

Properties

Link copied to clipboard
val clusterings: Output<List<String>>?

Specifies column names to use for data clustering. Up to four top-level columns are allowed, and should be specified in descending priority order.

Link copied to clipboard
val creationTime: Output<Int>

The time when this table was created, in milliseconds since the epoch.

Link copied to clipboard
val datasetId: Output<String>

The dataset ID to create the table in. Changing this forces a new resource to be created.

Link copied to clipboard

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.

Link copied to clipboard
val description: Output<String>?

The field description.

Link copied to clipboard

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.

Link copied to clipboard
val etag: Output<String>

A hash of the resource.

Link copied to clipboard
val expirationTime: Output<Int>

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.

Link copied to clipboard

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.

Link copied to clipboard
val friendlyName: Output<String>?

A descriptive name for the table.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val labels: Output<Map<String, String>>?

A mapping of labels to assign to the resource.

Link copied to clipboard
val lastModifiedTime: Output<Int>

The time when this table was last modified, in milliseconds since the epoch.

Link copied to clipboard
val location: Output<String>

The geographic location where the table resides. This value is inherited from the dataset.

Link copied to clipboard

If specified, configures this table as a materialized view. Structure is documented below.

Link copied to clipboard
val maxStaleness: Output<String>?

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 type.

Link copied to clipboard
val numBytes: Output<Int>

The size of this table in bytes, excluding any data in the streaming buffer.

Link copied to clipboard
val numLongTermBytes: Output<Int>

The number of bytes in the table that are considered "long-term storage".

Link copied to clipboard
val numRows: Output<Int>

The number of rows of data in this table, excluding any data in the streaming buffer.

Link copied to clipboard
val project: Output<String>

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

If specified, configures range-based partitioning for this table. Structure is documented below.

Link copied to clipboard
val schema: Output<String>

A JSON schema for the external table. Schema is required for CSV and JSON formats if autodetect is not on. Schema is disallowed for Google Cloud Bigtable, Cloud Datastore backups, Avro, Iceberg, ORC and Parquet formats. ~>NOTE: Because this field expects a JSON string, any changes to the string will create a diff, even if the JSON itself hasn't changed. Furthermore drift for this field cannot not be detected because BigQuery only uses this schema to compute the effective schema for the table, therefore any changes on the configured value will force the table to be recreated. This schema is effectively only applied when creating a table from an external datasource, after creation the computed schema will be stored in google_bigquery_table.schema ~>NOTE: If you set external_data_configuration.connection_id, the table schema must be specified using the top-level schema field documented above.

Link copied to clipboard
val selfLink: Output<String>

The URI of the created resource.

Link copied to clipboard

Defines the primary key and foreign keys. Structure is documented below.

Link copied to clipboard
val tableId: Output<String>

A unique ID for the resource. Changing this forces a new resource to be created.

Link copied to clipboard

If specified, configures time-based partitioning for this table. Structure is documented below.

Link copied to clipboard
val type: Output<String>

The supported types are DAY, HOUR, MONTH, and YEAR, which will generate one partition per day, hour, month, and year, respectively.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val view: Output<TableView>?

If specified, configures this table as a view. Structure is documented below.