File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1021,6 +1021,23 @@ def friendly_name(self):
1021
1021
1022
1022
view_use_legacy_sql = property (_view_use_legacy_sql_getter )
1023
1023
1024
+ @property
1025
+ def clustering_fields (self ):
1026
+ """Union[List[str], None]: Fields defining clustering for the table
1027
+
1028
+ (Defaults to :data:`None`).
1029
+
1030
+ Clustering fields are immutable after table creation.
1031
+
1032
+ .. note::
1033
+
1034
+ As of 2018-06-29, clustering fields cannot be set on a table
1035
+ which does not also have time partioning defined.
1036
+ """
1037
+ prop = self ._properties .get ("clustering" )
1038
+ if prop is not None :
1039
+ return list (prop .get ("fields" , ()))
1040
+
1024
1041
@classmethod
1025
1042
def from_string (cls , full_table_id ):
1026
1043
"""Construct a table from fully-qualified table ID.
Original file line number Diff line number Diff line change @@ -1148,6 +1148,7 @@ def test_ctor(self):
1148
1148
"expirationMs" : "10000" ,
1149
1149
},
1150
1150
"labels" : {"some-stuff" : "this-is-a-label" },
1151
+ "clustering" : {"fields" : ["string" ]},
1151
1152
}
1152
1153
1153
1154
table = self ._make_one (resource )
@@ -1170,6 +1171,7 @@ def test_ctor(self):
1170
1171
self .assertEqual (table .time_partitioning .field , "mycolumn" )
1171
1172
self .assertEqual (table .labels ["some-stuff" ], "this-is-a-label" )
1172
1173
self .assertIsNone (table .view_use_legacy_sql )
1174
+ self .assertEqual (table .clustering_fields , ["string" ])
1173
1175
1174
1176
with warnings .catch_warnings (record = True ) as warned :
1175
1177
self .assertEqual (table .partitioning_type , "DAY" )
@@ -1222,6 +1224,7 @@ def test_ctor_missing_properties(self):
1222
1224
self .assertEqual (table .table_id , "testtable" )
1223
1225
self .assertIsNone (table .created )
1224
1226
self .assertIsNone (table .expires )
1227
+ self .assertIsNone (table .clustering_fields )
1225
1228
self .assertIsNone (table .full_table_id )
1226
1229
self .assertIsNone (table .friendly_name )
1227
1230
self .assertIsNone (table .table_type )
You can’t perform that action at this time.
0 commit comments