@@ -152,6 +152,10 @@ type TableMetadata struct {
152152 // Present only if the table has primary or foreign keys.
153153 TableConstraints * TableConstraints
154154
155+ // MaxStaleness staleness of data that could be
156+ // returned when the table (or stale MV) is queried.
157+ MaxStaleness * IntervalValue
158+
155159 // The tags associated with this table. Tag
156160 // keys are globally unique. See additional information on tags
157161 // (https://cloud.google.com/iam/docs/tags-access-control#definitions).
@@ -333,6 +337,8 @@ type MaterializedViewDefinition struct {
333337
334338 // MaxStaleness of data that could be returned when materialized
335339 // view is queried.
340+ //
341+ // Deprecated: use Table level MaxStaleness.
336342 MaxStaleness * IntervalValue
337343}
338344
@@ -817,6 +823,9 @@ func (tm *TableMetadata) toBQ() (*bq.Table, error) {
817823 }
818824 }
819825 }
826+ if tm .MaxStaleness != nil {
827+ t .MaxStaleness = tm .MaxStaleness .String ()
828+ }
820829 if tm .ResourceTags != nil {
821830 t .ResourceTags = make (map [string ]string )
822831 for k , v := range tm .ResourceTags {
@@ -942,6 +951,9 @@ func bqToTableMetadata(t *bq.Table, c *Client) (*TableMetadata, error) {
942951 ForeignKeys : bqToForeignKeys (t .TableConstraints , c ),
943952 }
944953 }
954+ if t .MaxStaleness != "" {
955+ md .MaxStaleness , _ = ParseInterval (t .MaxStaleness )
956+ }
945957 if t .ResourceTags != nil {
946958 md .ResourceTags = make (map [string ]string )
947959 for k , v := range t .ResourceTags {
@@ -1122,6 +1134,10 @@ func (tm *TableMetadataToUpdate) toBQ() (*bq.Table, error) {
11221134 t .TableConstraints .ForceSendFields = append (t .TableConstraints .ForceSendFields , "ForeignKeys" )
11231135 }
11241136 }
1137+ if tm .MaxStaleness != nil {
1138+ t .MaxStaleness = tm .MaxStaleness .String ()
1139+ forceSend ("MaxStaleness" )
1140+ }
11251141 if tm .ResourceTags != nil {
11261142 t .ResourceTags = make (map [string ]string )
11271143 for k , v := range tm .ResourceTags {
@@ -1210,6 +1226,10 @@ type TableMetadataToUpdate struct {
12101226 // such as primary and foreign keys.
12111227 TableConstraints * TableConstraints
12121228
1229+ // MaxStaleness staleness of data that could be
1230+ // returned when the table (or stale MV) is queried.
1231+ MaxStaleness * IntervalValue
1232+
12131233 // The tags associated with this table. Tag
12141234 // keys are globally unique. See additional information on tags
12151235 // (https://cloud.google.com/iam/docs/tags-access-control#definitions).
0 commit comments