@@ -58,6 +58,9 @@ type DatasetMetadata struct {
5858 // More information: https://cloud.google.com/bigquery/docs/reference/standard-sql/collation-concepts
5959 DefaultCollation string
6060
61+ // For externally defined datasets, contains information about the configuration.
62+ ExternalDatasetReference * ExternalDatasetReference
63+
6164 // MaxTimeTravel represents the number of hours for the max time travel for all tables
6265 // in the dataset. Durations are rounded towards zero for the nearest hourly value.
6366 MaxTimeTravel time.Duration
@@ -135,6 +138,9 @@ type DatasetMetadataToUpdate struct {
135138 // created in the dataset.
136139 DefaultCollation optional.String
137140
141+ // For externally defined datasets, contains information about the configuration.
142+ ExternalDatasetReference * ExternalDatasetReference
143+
138144 // MaxTimeTravel represents the number of hours for the max time travel for all tables
139145 // in the dataset. Durations are rounded towards zero for the nearest hourly value.
140146 MaxTimeTravel optional.Duration
@@ -239,6 +245,9 @@ func (dm *DatasetMetadata) toBQ() (*bq.Dataset, error) {
239245 if dm .DefaultEncryptionConfig != nil {
240246 ds .DefaultEncryptionConfiguration = dm .DefaultEncryptionConfig .toBQ ()
241247 }
248+ if dm .ExternalDatasetReference != nil {
249+ ds .ExternalDatasetReference = dm .ExternalDatasetReference .toBQ ()
250+ }
242251 return ds , nil
243252}
244253
@@ -304,6 +313,7 @@ func bqToDatasetMetadata(d *bq.Dataset, c *Client) (*DatasetMetadata, error) {
304313 DefaultTableExpiration : time .Duration (d .DefaultTableExpirationMs ) * time .Millisecond ,
305314 DefaultPartitionExpiration : time .Duration (d .DefaultPartitionExpirationMs ) * time .Millisecond ,
306315 DefaultCollation : d .DefaultCollation ,
316+ ExternalDatasetReference : bqToExternalDatasetReference (d .ExternalDatasetReference ),
307317 MaxTimeTravel : time .Duration (d .MaxTimeTravelHours ) * time .Hour ,
308318 StorageBillingModel : d .StorageBillingModel ,
309319 DefaultEncryptionConfig : bqToEncryptionConfig (d .DefaultEncryptionConfiguration ),
@@ -395,6 +405,10 @@ func (dm *DatasetMetadataToUpdate) toBQ() (*bq.Dataset, error) {
395405 ds .DefaultCollation = optional .ToString (dm .DefaultCollation )
396406 forceSend ("DefaultCollation" )
397407 }
408+ if dm .ExternalDatasetReference != nil {
409+ ds .ExternalDatasetReference = dm .ExternalDatasetReference .toBQ ()
410+ forceSend ("ExternalDatasetReference" )
411+ }
398412 if dm .MaxTimeTravel != nil {
399413 dur := optional .ToDuration (dm .MaxTimeTravel )
400414 if dur == 0 {
@@ -936,3 +950,33 @@ func bqToDatasetAccessEntry(entry *bq.DatasetAccessEntry, c *Client) *DatasetAcc
936950 TargetTypes : entry .TargetTypes ,
937951 }
938952}
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