@@ -58,6 +58,9 @@ type DatasetMetadata struct {
58
58
// More information: https://cloud.google.com/bigquery/docs/reference/standard-sql/collation-concepts
59
59
DefaultCollation string
60
60
61
+ // For externally defined datasets, contains information about the configuration.
62
+ ExternalDatasetReference * ExternalDatasetReference
63
+
61
64
// MaxTimeTravel represents the number of hours for the max time travel for all tables
62
65
// in the dataset. Durations are rounded towards zero for the nearest hourly value.
63
66
MaxTimeTravel time.Duration
@@ -135,6 +138,9 @@ type DatasetMetadataToUpdate struct {
135
138
// created in the dataset.
136
139
DefaultCollation optional.String
137
140
141
+ // For externally defined datasets, contains information about the configuration.
142
+ ExternalDatasetReference * ExternalDatasetReference
143
+
138
144
// MaxTimeTravel represents the number of hours for the max time travel for all tables
139
145
// in the dataset. Durations are rounded towards zero for the nearest hourly value.
140
146
MaxTimeTravel optional.Duration
@@ -239,6 +245,9 @@ func (dm *DatasetMetadata) toBQ() (*bq.Dataset, error) {
239
245
if dm .DefaultEncryptionConfig != nil {
240
246
ds .DefaultEncryptionConfiguration = dm .DefaultEncryptionConfig .toBQ ()
241
247
}
248
+ if dm .ExternalDatasetReference != nil {
249
+ ds .ExternalDatasetReference = dm .ExternalDatasetReference .toBQ ()
250
+ }
242
251
return ds , nil
243
252
}
244
253
@@ -304,6 +313,7 @@ func bqToDatasetMetadata(d *bq.Dataset, c *Client) (*DatasetMetadata, error) {
304
313
DefaultTableExpiration : time .Duration (d .DefaultTableExpirationMs ) * time .Millisecond ,
305
314
DefaultPartitionExpiration : time .Duration (d .DefaultPartitionExpirationMs ) * time .Millisecond ,
306
315
DefaultCollation : d .DefaultCollation ,
316
+ ExternalDatasetReference : bqToExternalDatasetReference (d .ExternalDatasetReference ),
307
317
MaxTimeTravel : time .Duration (d .MaxTimeTravelHours ) * time .Hour ,
308
318
StorageBillingModel : d .StorageBillingModel ,
309
319
DefaultEncryptionConfig : bqToEncryptionConfig (d .DefaultEncryptionConfiguration ),
@@ -395,6 +405,10 @@ func (dm *DatasetMetadataToUpdate) toBQ() (*bq.Dataset, error) {
395
405
ds .DefaultCollation = optional .ToString (dm .DefaultCollation )
396
406
forceSend ("DefaultCollation" )
397
407
}
408
+ if dm .ExternalDatasetReference != nil {
409
+ ds .ExternalDatasetReference = dm .ExternalDatasetReference .toBQ ()
410
+ forceSend ("ExternalDatasetReference" )
411
+ }
398
412
if dm .MaxTimeTravel != nil {
399
413
dur := optional .ToDuration (dm .MaxTimeTravel )
400
414
if dur == 0 {
@@ -936,3 +950,33 @@ func bqToDatasetAccessEntry(entry *bq.DatasetAccessEntry, c *Client) *DatasetAcc
936
950
TargetTypes : entry .TargetTypes ,
937
951
}
938
952
}
953
+
954
+ // ExternalDatasetReference provides information about external dataset metadata.
955
+ type ExternalDatasetReference struct {
956
+ //The connection id that is used to access the external_source.
957
+ // Format: projects/{project_id}/locations/{location_id}/connections/{connection_id}
958
+ Connection string
959
+
960
+ // External source that backs this dataset.
961
+ ExternalSource string
962
+ }
963
+
964
+ func bqToExternalDatasetReference (bq * bq.ExternalDatasetReference ) * ExternalDatasetReference {
965
+ if bq == nil {
966
+ return nil
967
+ }
968
+ return & ExternalDatasetReference {
969
+ Connection : bq .Connection ,
970
+ ExternalSource : bq .ExternalSource ,
971
+ }
972
+ }
973
+
974
+ func (edr * ExternalDatasetReference ) toBQ () * bq.ExternalDatasetReference {
975
+ if edr == nil {
976
+ return nil
977
+ }
978
+ return & bq.ExternalDatasetReference {
979
+ Connection : edr .Connection ,
980
+ ExternalSource : edr .ExternalSource ,
981
+ }
982
+ }
0 commit comments