@@ -666,6 +666,35 @@ Creation, truncation and append actions occur as one atomic update upon job comp
666666Requires destinationTable to be set. For standard SQL queries, this flag is ignored and large results are always allowed.
667667However, you must still set destinationTable when result size exceeds the allowed maximum response size.` ,
668668 },
669+ "connection_properties" : {
670+ Type : schema .TypeList ,
671+ Optional : true ,
672+ ForceNew : true ,
673+ Description : `Connection properties to customize query behavior. Under JDBC, these correspond
674+ directly to connection properties passed to the DriverManager. Under ODBC, these
675+ correspond to properties in the connection string.` ,
676+ Elem : & schema.Resource {
677+ Schema : map [string ]* schema.Schema {
678+ "key" : {
679+ Type : schema .TypeString ,
680+ Required : true ,
681+ ForceNew : true ,
682+ Description : `The key of the property to set. Currently supported connection properties:
683+ * 'dataset_project_id': represents the default project for datasets that are used in the query
684+ * 'time_zone': represents the default timezone used to run the query
685+ * 'session_id': associates the query with a given session
686+ * 'query_label': associates the query with a given job label
687+ * 'service_account': indicates the service account to use to run a continuous query` ,
688+ },
689+ "value" : {
690+ Type : schema .TypeString ,
691+ Required : true ,
692+ ForceNew : true ,
693+ Description : `The value of the property to set.` ,
694+ },
695+ },
696+ },
697+ },
669698 "continuous" : {
670699 Type : schema .TypeBool ,
671700 Optional : true ,
@@ -1361,6 +1390,8 @@ func flattenBigQueryJobConfigurationQuery(v interface{}, d *schema.ResourceData,
13611390 flattenBigQueryJobConfigurationQueryScriptOptions (original ["scriptOptions" ], d , config )
13621391 transformed ["continuous" ] =
13631392 flattenBigQueryJobConfigurationQueryContinuous (original ["continuous" ], d , config )
1393+ transformed ["connection_properties" ] =
1394+ flattenBigQueryJobConfigurationQueryConnectionProperties (original ["connectionProperties" ], d , config )
13641395 return []interface {}{transformed }
13651396}
13661397func flattenBigQueryJobConfigurationQueryQuery (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
@@ -1548,6 +1579,33 @@ func flattenBigQueryJobConfigurationQueryContinuous(v interface{}, d *schema.Res
15481579 return v
15491580}
15501581
1582+ func flattenBigQueryJobConfigurationQueryConnectionProperties (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1583+ if v == nil {
1584+ return v
1585+ }
1586+ l := v .([]interface {})
1587+ transformed := make ([]interface {}, 0 , len (l ))
1588+ for _ , raw := range l {
1589+ original := raw .(map [string ]interface {})
1590+ if len (original ) < 1 {
1591+ // Do not include empty json objects coming back from the api
1592+ continue
1593+ }
1594+ transformed = append (transformed , map [string ]interface {}{
1595+ "key" : flattenBigQueryJobConfigurationQueryConnectionPropertiesKey (original ["key" ], d , config ),
1596+ "value" : flattenBigQueryJobConfigurationQueryConnectionPropertiesValue (original ["value" ], d , config ),
1597+ })
1598+ }
1599+ return transformed
1600+ }
1601+ func flattenBigQueryJobConfigurationQueryConnectionPropertiesKey (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1602+ return v
1603+ }
1604+
1605+ func flattenBigQueryJobConfigurationQueryConnectionPropertiesValue (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1606+ return v
1607+ }
1608+
15511609func flattenBigQueryJobConfigurationLoad (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
15521610 if v == nil {
15531611 return nil
@@ -2315,6 +2373,13 @@ func expandBigQueryJobConfigurationQuery(v interface{}, d tpgresource.TerraformR
23152373 transformed ["continuous" ] = transformedContinuous
23162374 }
23172375
2376+ transformedConnectionProperties , err := expandBigQueryJobConfigurationQueryConnectionProperties (original ["connection_properties" ], d , config )
2377+ if err != nil {
2378+ return nil , err
2379+ } else if val := reflect .ValueOf (transformedConnectionProperties ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2380+ transformed ["connectionProperties" ] = transformedConnectionProperties
2381+ }
2382+
23182383 return transformed , nil
23192384}
23202385
@@ -2560,6 +2625,43 @@ func expandBigQueryJobConfigurationQueryContinuous(v interface{}, d tpgresource.
25602625 return v , nil
25612626}
25622627
2628+ func expandBigQueryJobConfigurationQueryConnectionProperties (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2629+ l := v .([]interface {})
2630+ req := make ([]interface {}, 0 , len (l ))
2631+ for _ , raw := range l {
2632+ if raw == nil {
2633+ continue
2634+ }
2635+ original := raw .(map [string ]interface {})
2636+ transformed := make (map [string ]interface {})
2637+
2638+ transformedKey , err := expandBigQueryJobConfigurationQueryConnectionPropertiesKey (original ["key" ], d , config )
2639+ if err != nil {
2640+ return nil , err
2641+ } else if val := reflect .ValueOf (transformedKey ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2642+ transformed ["key" ] = transformedKey
2643+ }
2644+
2645+ transformedValue , err := expandBigQueryJobConfigurationQueryConnectionPropertiesValue (original ["value" ], d , config )
2646+ if err != nil {
2647+ return nil , err
2648+ } else if val := reflect .ValueOf (transformedValue ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2649+ transformed ["value" ] = transformedValue
2650+ }
2651+
2652+ req = append (req , transformed )
2653+ }
2654+ return req , nil
2655+ }
2656+
2657+ func expandBigQueryJobConfigurationQueryConnectionPropertiesKey (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2658+ return v , nil
2659+ }
2660+
2661+ func expandBigQueryJobConfigurationQueryConnectionPropertiesValue (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2662+ return v , nil
2663+ }
2664+
25632665func expandBigQueryJobConfigurationLoad (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
25642666 l := v .([]interface {})
25652667 if len (l ) == 0 || l [0 ] == nil {
0 commit comments