You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support replica materialized view in resource_bigquery_table in the beta provider (#9773) (#6865)
* support replica materialized view in resource_bigquery_table
* fix typo
* add unit tests
* fix white spaces
* fix the condition check for table_replication_info in Update
* create source materialized view in unit tests using DDL instead of table API
* add missing google-beta provider declarations in unit test
* create source table using DDL in unit test
* Revert "create source table using DDL in unit test"
This reverts commit 232a7ac431114cd405f0cec858bb0496d48fd07c.
* reorder input args in unit tests
* remove wrong project declaration in unit tests
* remove update check, make the new fields forcenew, and add default to replication_interval_ms
* add ForceNew to table_replication_info
[upstream:256f7f56789ee965c2e7582735140de383270400]
Signed-off-by: Modular Magician <[email protected]>
// TableReplicationInfo: [Optional] Replication info of a table created using `AS REPLICA` DDL like: `CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv`.
1256
+
"table_replication_info": {
1257
+
Type: schema.TypeList,
1258
+
Optional: true,
1259
+
ForceNew: true,
1260
+
MaxItems: 1,
1261
+
Description: `Replication info of a table created using "AS REPLICA" DDL like: "CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv".`,
1262
+
Elem: &schema.Resource{
1263
+
Schema: map[string]*schema.Schema{
1264
+
"source_project_id": {
1265
+
Type: schema.TypeString,
1266
+
Required: true,
1267
+
ForceNew: true,
1268
+
Description: `The ID of the source project.`,
1269
+
},
1270
+
"source_dataset_id": {
1271
+
Type: schema.TypeString,
1272
+
Required: true,
1273
+
ForceNew: true,
1274
+
Description: `The ID of the source dataset.`,
1275
+
},
1276
+
"source_table_id": {
1277
+
Type: schema.TypeString,
1278
+
Required: true,
1279
+
ForceNew: true,
1280
+
Description: `The ID of the source materialized view.`,
1281
+
},
1282
+
"replication_interval_ms": {
1283
+
Type: schema.TypeInt,
1284
+
Default: 300000,
1285
+
Optional: true,
1286
+
ForceNew: true,
1287
+
Description: `The interval at which the source materialized view is polled for updates. The default is 300000.`,
1288
+
},
1289
+
},
1290
+
},
1291
+
},
1255
1292
},
1256
1293
UseJSONNumber: true,
1257
1294
}
@@ -1388,9 +1425,49 @@ func resourceBigQueryTableCreate(d *schema.ResourceData, meta interface{}) error
replicationDDL=fmt.Sprintf("%s AS REPLICA OF %s.%s.%s", replicationDDL, tableReplicationInfo["source_project_id"], tableReplicationInfo["source_dataset_id"], tableReplicationInfo["source_table_id"])
1443
+
useLegacySQL:=false
1444
+
1445
+
req:=&bigquery.QueryRequest{
1446
+
Query: replicationDDL,
1447
+
UseLegacySql: &useLegacySQL,
1448
+
}
1449
+
1450
+
log.Printf("[INFO] Creating a replica materialized view with DDL: '%s'", replicationDDL)
0 commit comments