@@ -489,6 +489,39 @@ func TestAccBigQueryTable_MaterializedView_DailyTimePartioning_Update(t *testing
489
489
})
490
490
}
491
491
492
+ func TestAccBigQueryTable_MaterializedView_NonIncremental_basic (t * testing.T ) {
493
+ t .Parallel ()
494
+
495
+ datasetID := fmt .Sprintf ("tf_test_%s" , acctest .RandString (t , 10 ))
496
+ tableID := fmt .Sprintf ("tf_test_%s" , acctest .RandString (t , 10 ))
497
+ materialized_viewID := fmt .Sprintf ("tf_test_%s" , acctest .RandString (t , 10 ))
498
+ 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 )
499
+ maxStaleness := "0-0 0 10:0:0"
500
+
501
+ acctest .VcrTest (t , resource.TestCase {
502
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
503
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
504
+ CheckDestroy : testAccCheckBigQueryTableDestroyProducer (t ),
505
+ Steps : []resource.TestStep {
506
+ {
507
+ Config : testAccBigQueryTableWithMatViewNonIncremental_basic (datasetID , tableID , materialized_viewID , query , maxStaleness ),
508
+ },
509
+ {
510
+ ResourceName : "google_bigquery_table.test" ,
511
+ ImportState : true ,
512
+ ImportStateVerify : true ,
513
+ ImportStateVerifyIgnore : []string {"etag" , "last_modified_time" , "deletion_protection" },
514
+ },
515
+ {
516
+ ResourceName : "google_bigquery_table.mv_test" ,
517
+ ImportState : true ,
518
+ ImportStateVerify : true ,
519
+ ImportStateVerifyIgnore : []string {"etag" , "last_modified_time" , "deletion_protection" },
520
+ },
521
+ },
522
+ })
523
+ }
524
+
492
525
func TestAccBigQueryExternalDataTable_parquet (t * testing.T ) {
493
526
t .Parallel ()
494
527
@@ -1840,6 +1873,86 @@ resource "google_bigquery_table" "mv_test" {
1840
1873
` , datasetID , tableID , mViewID , enable_refresh , refresh_interval , query )
1841
1874
}
1842
1875
1876
+ func testAccBigQueryTableWithMatViewNonIncremental_basic (datasetID , tableID , mViewID , query , maxStaleness string ) string {
1877
+ return fmt .Sprintf (`
1878
+ resource "google_bigquery_dataset" "test" {
1879
+ dataset_id = "%s"
1880
+ }
1881
+
1882
+ resource "google_bigquery_table" "test" {
1883
+ deletion_protection = false
1884
+ table_id = "%s"
1885
+ dataset_id = google_bigquery_dataset.test.dataset_id
1886
+
1887
+ time_partitioning {
1888
+ type = "DAY"
1889
+ field = "ts"
1890
+ require_partition_filter = true
1891
+ }
1892
+ clustering = ["some_int", "some_string"]
1893
+ schema = <<EOH
1894
+ [
1895
+ {
1896
+ "name": "ts",
1897
+ "type": "TIMESTAMP"
1898
+ },
1899
+ {
1900
+ "name": "some_string",
1901
+ "type": "STRING"
1902
+ },
1903
+ {
1904
+ "name": "some_int",
1905
+ "type": "INTEGER"
1906
+ },
1907
+ {
1908
+ "name": "city",
1909
+ "type": "RECORD",
1910
+ "fields": [
1911
+ {
1912
+ "name": "id",
1913
+ "type": "INTEGER"
1914
+ },
1915
+ {
1916
+ "name": "coord",
1917
+ "type": "RECORD",
1918
+ "fields": [
1919
+ {
1920
+ "name": "lon",
1921
+ "type": "FLOAT"
1922
+ }
1923
+ ]
1924
+ }
1925
+ ]
1926
+ }
1927
+ ]
1928
+ EOH
1929
+
1930
+ }
1931
+
1932
+ resource "google_bigquery_table" "mv_test" {
1933
+ deletion_protection = false
1934
+ table_id = "%s"
1935
+ dataset_id = google_bigquery_dataset.test.dataset_id
1936
+
1937
+ time_partitioning {
1938
+ type = "DAY"
1939
+ field = "ts"
1940
+ }
1941
+
1942
+ materialized_view {
1943
+ query = "%s"
1944
+ allow_non_incremental_definition = true
1945
+ }
1946
+
1947
+ depends_on = [
1948
+ google_bigquery_table.test,
1949
+ ]
1950
+
1951
+ max_staleness = "%s"
1952
+ }
1953
+ ` , datasetID , tableID , mViewID , query , maxStaleness )
1954
+ }
1955
+
1843
1956
func testAccBigQueryTableUpdated (datasetID , tableID string ) string {
1844
1957
return fmt .Sprintf (`
1845
1958
resource "google_bigquery_dataset" "test" {
0 commit comments