【问题标题】:External Bigquery hive partition table created for dataset but not able to view the column with partition key为数据集创建了外部 Bigquery 配置单元分区表,但无法查看具有分区键的列
【发布时间】:2020-07-15 09:35:11
【问题描述】:

我创建了一个用于在 Bigquery 中创建数据集和外部表的 terraform 脚本。下面是 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 }

我能够在数据集下创建 hive 分区外部表,缺少将分区键创建为列。但是当我使用相同的架构从谷歌云控制台创建时,我能够正确查看表详细信息部分中的分区键列。

terraform 脚本在创建表时缺少分区键列。

我不确定脚本中还缺少什么。

【问题讨论】:

  • 第四栏是什么意思?你可以说得更详细点吗?也许通过准确显示您在手动创建表格和使用 terraform 时看到的内容
  • 请分享用于手动创建表的命令,以及用于获取架构信息的命令和屏幕截图可能有助于弄清楚发生了什么。
  • 更新了问题。如果不清楚,请告诉我。
  • 很奇怪,如果分区不支持出现问题,gcloud 命令也必须失败;尽管如此,表的创建没有问题,我认为 Terraform 使用 BigQuery REST API 来创建表,我建议您自己使用 REST API 进行测试,而不是使用 gcloud 命令来验证它是否也有效。跨度>

标签: google-bigquery dataset bq


【解决方案1】:

schema 属性必须位于 external_data_configuration 块中,而不是顶级 google_bigquery_table 块中。

我不知道为什么这两个位置都有效,但只有一个尊重分区字段。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-12
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-21
    相关资源
    最近更新 更多