@@ -58,6 +58,10 @@ type DatasetMetadata struct {
5858 // More information: https://cloud.google.com/bigquery/docs/reference/standard-sql/collation-concepts
5959 DefaultCollation string
6060
61+ // MaxTimeTravelHours represents the number of hours for the max time travel for all tables
62+ // in the dataset. Durations are rounded towards zero for the nearest hourly value.
63+ MaxTimeTravelHours time.Duration
64+
6165 // Storage billing model to be used for all tables in the dataset.
6266 // Can be set to PHYSICAL. Default is LOGICAL.
6367 // Once you create a dataset with storage billing model set to physical bytes, you can't change it back to using logical bytes again.
@@ -131,6 +135,10 @@ type DatasetMetadataToUpdate struct {
131135 // created in the dataset.
132136 DefaultCollation optional.String
133137
138+ // MaxTimeTravelHours represents the number of hours for the max time travel for all tables
139+ // in the dataset. Durations are rounded towards zero for the nearest hourly value.
140+ MaxTimeTravelHours optional.Duration
141+
134142 // Storage billing model to be used for all tables in the dataset.
135143 // Can be set to PHYSICAL. Default is LOGICAL.
136144 // Once you change a dataset's storage billing model to use physical bytes, you can't change it back to using logical bytes again.
@@ -208,6 +216,7 @@ func (dm *DatasetMetadata) toBQ() (*bq.Dataset, error) {
208216 ds .DefaultTableExpirationMs = int64 (dm .DefaultTableExpiration / time .Millisecond )
209217 ds .DefaultPartitionExpirationMs = int64 (dm .DefaultPartitionExpiration / time .Millisecond )
210218 ds .DefaultCollation = dm .DefaultCollation
219+ ds .MaxTimeTravelHours = int64 (dm .MaxTimeTravelHours / time .Hour )
211220 ds .StorageBillingModel = string (dm .StorageBillingModel )
212221 ds .Labels = dm .Labels
213222 var err error
@@ -295,6 +304,7 @@ func bqToDatasetMetadata(d *bq.Dataset, c *Client) (*DatasetMetadata, error) {
295304 DefaultTableExpiration : time .Duration (d .DefaultTableExpirationMs ) * time .Millisecond ,
296305 DefaultPartitionExpiration : time .Duration (d .DefaultPartitionExpirationMs ) * time .Millisecond ,
297306 DefaultCollation : d .DefaultCollation ,
307+ MaxTimeTravelHours : time .Duration (d .MaxTimeTravelHours ) * time .Hour ,
298308 StorageBillingModel : d .StorageBillingModel ,
299309 DefaultEncryptionConfig : bqToEncryptionConfig (d .DefaultEncryptionConfiguration ),
300310 Description : d .Description ,
@@ -385,6 +395,15 @@ func (dm *DatasetMetadataToUpdate) toBQ() (*bq.Dataset, error) {
385395 ds .DefaultCollation = optional .ToString (dm .DefaultCollation )
386396 forceSend ("DefaultCollation" )
387397 }
398+ if dm .MaxTimeTravelHours != nil {
399+ dur := optional .ToDuration (dm .MaxTimeTravelHours )
400+ if dur == 0 {
401+ // Send a null to delete the field.
402+ ds .NullFields = append (ds .NullFields , "MaxTimeTravelHours" )
403+ } else {
404+ ds .MaxTimeTravelHours = int64 (dur / time .Hour )
405+ }
406+ }
388407 if dm .StorageBillingModel != nil {
389408 ds .StorageBillingModel = optional .ToString (dm .StorageBillingModel )
390409 forceSend ("StorageBillingModel" )
0 commit comments