diff --git a/README.md b/README.md index 92a4a787..1d51a24a 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ This module provisions a dataset and a list of tables with associated JSON schem | deletion\_protection | Whether or not to allow deletion of tables and external tables defined by this module. Can be overriden by table-level deletion\_protection configuration. | `bool` | `false` | no | | description | Dataset description. | `string` | `null` | no | | encryption\_key | Default encryption key to apply to the dataset. Defaults to null (Google-managed). | `string` | `null` | no | -| external\_tables | A list of objects which include table\_id, expiration\_time, external\_data\_configuration, and labels. |
list(object({
table_id = string,
description = optional(string),
autodetect = bool,
compression = string,
ignore_unknown_values = bool,
max_bad_records = number,
schema = string,
source_format = string,
source_uris = list(string),
csv_options = object({
quote = string,
allow_jagged_rows = bool,
allow_quoted_newlines = bool,
encoding = string,
field_delimiter = string,
skip_leading_rows = number,
}),
google_sheets_options = object({
range = string,
skip_leading_rows = number,
}),
hive_partitioning_options = object({
mode = string,
source_uri_prefix = string,
}),
expiration_time = optional(string, null),
max_staleness = optional(string),
deletion_protection = optional(bool),
labels = optional(map(string), {}),
})) | `[]` | no |
+| external\_tables | A list of objects which include table\_id, expiration\_time, external\_data\_configuration, and labels. | list(object({
table_id = string,
description = optional(string),
autodetect = bool,
compression = string,
ignore_unknown_values = bool,
max_bad_records = number,
schema = string,
connection_id = optional(string),
source_format = string,
source_uris = list(string),
csv_options = object({
quote = string,
allow_jagged_rows = bool,
allow_quoted_newlines = bool,
encoding = string,
field_delimiter = string,
skip_leading_rows = number,
}),
google_sheets_options = object({
range = string,
skip_leading_rows = number,
}),
hive_partitioning_options = object({
mode = string,
source_uri_prefix = string,
}),
expiration_time = optional(string, null),
max_staleness = optional(string),
deletion_protection = optional(bool),
labels = optional(map(string), {}),
})) | `[]` | no |
| location | The location of the dataset. For multi-region, US or EU can be provided. | `string` | `"US"` | no |
| materialized\_views | A list of objects which includes view\_id, view\_query, clustering, time\_partitioning, range\_partitioning, expiration\_time and labels | list(object({
view_id = string,
description = optional(string),
query = string,
enable_refresh = bool,
refresh_interval_ms = string,
clustering = optional(list(string), []),
time_partitioning = optional(object({
expiration_ms = string,
field = string,
type = string,
require_partition_filter = bool,
}), null),
range_partitioning = optional(object({
field = string,
range = object({
start = string,
end = string,
interval = string,
}),
}), null),
expiration_time = optional(string, null),
max_staleness = optional(string),
labels = optional(map(string), {}),
})) | `[]` | no |
| max\_time\_travel\_hours | Defines the time travel window in hours | `number` | `null` | no |
diff --git a/examples/multiple_tables/main.tf b/examples/multiple_tables/main.tf
index 9b94d658..cb822301 100644
--- a/examples/multiple_tables/main.tf
+++ b/examples/multiple_tables/main.tf
@@ -74,6 +74,7 @@ module "bigquery" {
max_bad_records = 0
source_format = "CSV"
schema = null
+ connection_id = null
expiration_time = 2524604400000 # 2050/01/01
labels = {
env = "devops"
diff --git a/main.tf b/main.tf
index a7ba03dc..1b37fd9c 100644
--- a/main.tf
+++ b/main.tf
@@ -186,6 +186,7 @@ resource "google_bigquery_table" "external_table" {
table_id = each.key
description = each.value["description"]
labels = each.value["labels"]
+ schema = each.value["connection_id"] != null ? each.value["schema"] : null
expiration_time = each.value["expiration_time"] != null ? each.value["expiration_time"] : 0
max_staleness = each.value["max_staleness"]
project = var.project_id
@@ -194,9 +195,10 @@ resource "google_bigquery_table" "external_table" {
external_data_configuration {
autodetect = each.value["autodetect"]
compression = each.value["compression"]
+ connection_id = each.value["connection_id"]
ignore_unknown_values = each.value["ignore_unknown_values"]
max_bad_records = each.value["max_bad_records"]
- schema = each.value["schema"]
+ schema = each.value["connection_id"] == null ? each.value["schema"] : null
source_format = each.value["source_format"]
source_uris = each.value["source_uris"]
diff --git a/metadata.display.yaml b/metadata.display.yaml
index b801a766..f98bd07f 100644
--- a/metadata.display.yaml
+++ b/metadata.display.yaml
@@ -71,6 +71,42 @@ spec:
value: GZIP
- label: NONE
value: NONE
+ csv_options:
+ name: csv_options
+ title: CSV Options
+ properties:
+ encoding:
+ name: encoding
+ title: Encoding
+ enumValueLabels:
+ - label: UTF-8
+ value: UTF-8
+ - label: ISO-8859-1
+ value: ISO-8859-1
+ skip_leading_rows:
+ name: skip_leading_rows
+ title: Skip Leading Rows
+ google_sheets_options:
+ name: google_sheets_options
+ title: Google Sheets Options
+ properties:
+ skip_leading_rows:
+ name: skip_leading_rows
+ title: Skip Leading Rows
+ hive_partitioning_options:
+ name: hive_partitioning_options
+ title: Hive Partitioning Options
+ properties:
+ mode:
+ name: mode
+ title: Mode
+ enumValueLabels:
+ - label: AUTO
+ value: AUTO
+ - label: STRINGS
+ value: STRINGS
+ - label: CUSTOM
+ value: CUSTOM
source_format:
name: source_format
title: Source Format
@@ -98,44 +134,6 @@ spec:
title: Source Uris
regexValidation: ^gs://([a-z0-9]([a-z0-9-.]*[a-z0-9])?)/([^#?]+)?$
validation: Must be a valid Google Cloud Storage URI.
- google_sheets_options:
- name: google_sheets_options
- title: Google Sheets Options
- properties:
- skip_leading_rows:
- name: skip_leading_rows
- title: Skip Leading Rows
- min: 0
- hive_partitioning_options:
- name: hive_partitioning_options
- title: Hive Partitioning Options
- properties:
- mode:
- name: mode
- title: Mode
- enumValueLabels:
- - label: AUTO
- value: AUTO
- - label: STRINGS
- value: STRINGS
- - label: CUSTOM
- value: CUSTOM
- csv_options:
- name: csv_options
- title: CSV Options
- properties:
- encoding:
- name: encoding
- title: Encoding
- enumValueLabels:
- - label: UTF-8
- value: UTF-8
- - label: ISO-8859-1
- value: ISO-8859-1
- skip_leading_rows:
- name: skip_leading_rows
- title: Skip Leading Rows
- min: 0
location:
name: location
title: Location
@@ -174,35 +172,6 @@ spec:
name: routines
title: Routines
properties:
- routine_id:
- name: routine_id
- title: Routine Id
- regexValidation: ^[A-Za-z_]{1,256}$
- validation: The routine ID must contain only letters, numbers, and underscores, and cannot start with a number.
- routine_type:
- name: routine_type
- title: Routine Type
- enumValueLabels:
- - label: SCALAR_FUNCTION
- value: SCALAR_FUNCTION
- - label: PROCEDURE
- value: PROCEDURE
- - label: TABLE_VALUED_FUNCTION
- value: TABLE_VALUED_FUNCTION
- language:
- name: language
- title: Language
- enumValueLabels:
- - label: SQL
- value: SQL
- - label: JAVASCRIPT
- value: JAVASCRIPT
- - label: PYTHON
- value: PYTHON
- - label: JAVA
- value: JAVA
- - label: SCALA
- value: SCALA
arguments:
name: arguments
title: Arguments
@@ -225,6 +194,35 @@ spec:
value: OUT
- label: INOUT
value: INOUT
+ language:
+ name: language
+ title: Language
+ enumValueLabels:
+ - label: SQL
+ value: SQL
+ - label: JAVASCRIPT
+ value: JAVASCRIPT
+ - label: PYTHON
+ value: PYTHON
+ - label: JAVA
+ value: JAVA
+ - label: SCALA
+ value: SCALA
+ routine_id:
+ name: routine_id
+ title: Routine Id
+ regexValidation: ^[A-Za-z_]{1,256}$
+ validation: The routine ID must contain only letters, numbers, and underscores, and cannot start with a number.
+ routine_type:
+ name: routine_type
+ title: Routine Type
+ enumValueLabels:
+ - label: SCALAR_FUNCTION
+ value: SCALAR_FUNCTION
+ - label: PROCEDURE
+ value: PROCEDURE
+ - label: TABLE_VALUED_FUNCTION
+ value: TABLE_VALUED_FUNCTION
storage_billing_model:
name: storage_billing_model
title: Storage Billing Model
diff --git a/metadata.yaml b/metadata.yaml
index c2af5d38..183f626b 100644
--- a/metadata.yaml
+++ b/metadata.yaml
@@ -185,6 +185,7 @@ spec:
ignore_unknown_values = bool,
max_bad_records = number,
schema = string,
+ connection_id = optional(string),
source_format = string,
source_uris = list(string),
csv_options = object({
diff --git a/variables.tf b/variables.tf
index 28ca7a8b..0eec806c 100644
--- a/variables.tf
+++ b/variables.tf
@@ -199,6 +199,7 @@ variable "external_tables" {
ignore_unknown_values = bool,
max_bad_records = number,
schema = string,
+ connection_id = optional(string),
source_format = string,
source_uris = list(string),
csv_options = object({