From 05d70fe405afd96a98c29ead5bc5bfd656ca8cb0 Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 12 Aug 2020 15:23:06 -0700 Subject: [PATCH] Upstream TPG #6920. (#3833) (#7012) Signed-off-by: Modular Magician --- .changelog/3833.txt | 4 ++++ google/resource_big_query_job.go | 13 +++++++------ website/docs/r/bigquery_job.html.markdown | 2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 .changelog/3833.txt diff --git a/.changelog/3833.txt b/.changelog/3833.txt new file mode 100644 index 00000000000..98b38997295 --- /dev/null +++ b/.changelog/3833.txt @@ -0,0 +1,4 @@ +```release-note:bug +bigquery: fixed issue with `use_legacy_sql` not being set to `false`. + +``` diff --git a/google/resource_big_query_job.go b/google/resource_big_query_job.go index b46b4eb8344..370eb2f0565 100644 --- a/google/resource_big_query_job.go +++ b/google/resource_big_query_job.go @@ -577,10 +577,12 @@ Creation, truncation and append actions occur as one atomic update upon job comp Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "query": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `SQL query text to execute. The useLegacySql field can be used to indicate whether the query uses legacy SQL or standard SQL.`, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `SQL query text to execute. The useLegacySql field can be used to indicate whether the query uses legacy SQL or standard SQL. +*NOTE*: queries containing [DML language](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language) +('DELETE', 'UPDATE', 'MERGE', 'INSERT') must specify 'create_disposition = ""' and 'write_disposition = ""'.`, }, "allow_large_results": { Type: schema.TypeBool, @@ -770,7 +772,6 @@ used to populate the schema and query results of the script job. Possible values ForceNew: true, Description: `Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL.`, - Default: true, }, "use_query_cache": { Type: schema.TypeBool, @@ -1864,7 +1865,7 @@ func expandBigQueryJobConfigurationQuery(v interface{}, d TerraformResourceData, transformedUseLegacySql, err := expandBigQueryJobConfigurationQueryUseLegacySql(original["use_legacy_sql"], d, config) if err != nil { return nil, err - } else if val := reflect.ValueOf(transformedUseLegacySql); val.IsValid() && !isEmptyValue(val) { + } else { transformed["useLegacySql"] = transformedUseLegacySql } diff --git a/website/docs/r/bigquery_job.html.markdown b/website/docs/r/bigquery_job.html.markdown index c7b63446398..2bde957a4ea 100644 --- a/website/docs/r/bigquery_job.html.markdown +++ b/website/docs/r/bigquery_job.html.markdown @@ -381,6 +381,8 @@ The `query` block supports: * `query` - (Required) SQL query text to execute. The useLegacySql field can be used to indicate whether the query uses legacy SQL or standard SQL. + *NOTE*: queries containing [DML language](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language) + (`DELETE`, `UPDATE`, `MERGE`, `INSERT`) must specify `create_disposition = ""` and `write_disposition = ""`. * `destination_table` - (Optional)