Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark BQ's materialized view query as ForceNew #3032

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4543.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigquery: fixed materialized view to be recreated when query changes
```
1 change: 1 addition & 0 deletions google-beta/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ func resourceBigQueryTable() *schema.Resource {
"query": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `A query whose result is persisted.`,
},
},
Expand Down
17 changes: 17 additions & 0 deletions google-beta/resource_bigquery_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"regexp"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -306,6 +307,7 @@ func TestAccBigQueryTable_MaterializedView_DailyTimePartioning_Basic(t *testing.
tableID := fmt.Sprintf("tf_test_%s", randString(t, 10))
materialized_viewID := fmt.Sprintf("tf_test_%s", randString(t, 10))
query := fmt.Sprintf("SELECT count(some_string) as count, some_int, ts FROM `%s.%s` WHERE DATE(ts) = '2019-01-01' GROUP BY some_int, ts", datasetID, tableID)
queryNew := strings.ReplaceAll(query, "2019", "2020")

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -327,6 +329,21 @@ func TestAccBigQueryTable_MaterializedView_DailyTimePartioning_Basic(t *testing.
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"etag", "last_modified_time", "deletion_protection"},
},
{
Config: testAccBigQueryTableWithMatViewDailyTimePartitioning_basic(datasetID, tableID, materialized_viewID, queryNew),
},
{
ResourceName: "google_bigquery_table.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"etag", "last_modified_time", "deletion_protection"},
},
{
ResourceName: "google_bigquery_table.mv_test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"etag", "last_modified_time", "deletion_protection"},
},
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion google-beta/resource_dataflow_flex_template_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
compute "google.golang.org/api/compute/v1"
"google.golang.org/api/compute/v1"
)

func TestAccDataflowFlexTemplateJob_basic(t *testing.T) {
Expand Down