我创建了一个用于在 Bigquery 中创建数据集和外部表的 terraform 脚本。下面是地形脚本
1 resource "google_bigquery_dataset" "bigquery" {
2 dataset_id = "${var.biqquery_dataset_id}"
3 friendly_name = "${var.friendly_name}"
4 description = "This is a test description"
5 location = "${var.location}"
6 project = "${var.project}"
7 default_table_expiration_ms = 3600000
8
9 labels = {
10 env = "default"
11 }
12 }
13
14 resource "google_bigquery_table" "bigquery_sheet" {
15 dataset_id = google_bigquery_dataset.bigquery.dataset_id
16 table_id = "${var.bigquery_table_id}"
17 project = "${var.project}"
18
19 schema = <<EOF
20 [
21 {
22 "name": "ip",
23 "type": "STRING",
24 "mode": "NULLABLE",
25 "description": "The Permalink"
26 },
27
28 {
29 "name": "fraudType",
30 "type": "STRING",
31 "mode": "NULLABLE",
32 "description": "The Permalink"
33 },
34
35 {
36 "name": "probability",
37 "type": "FLOAT",
38 "mode": "NULLABLE",
39 "description": "State where the head office is located"
40 }
41
42 ]
43 EOF
44
45 external_data_configuration {
46 autodetect = false
47 source_format = "${var.source_format}"
48
49 csv_options {
50 quote = ""
51 allow_jagged_rows = "false"
52 skip_leading_rows = "0"
53
54 }
55 hive_partitioning_options {
56 mode = "AUTO"
57 source_uri_prefix = "gs://xxxx/file/"
58 }
59 ignore_unknown_values = "false"
60 source_uris = [
61 "gs://xxxx/file/*",
62 ]
63 }
64 }
我能够在数据集下创建配置单元分区外部表,缺少将分区键创建为列。但是,当我从具有相同架构的谷歌云控制台创建时,我能够正确查看表详细信息部分中的分区键列。
terraform 脚本在创建表时缺少分区键列。
我不确定脚本中还缺少什么。