Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/bigquery_storage_v1/types/table.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

43 statements  

1# -*- coding: utf-8 -*- 

2# Copyright 2024 Google LLC 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15# 

16from __future__ import annotations 

17 

18from typing import MutableMapping, MutableSequence 

19 

20import proto # type: ignore 

21 

22__protobuf__ = proto.module( 

23 package="google.cloud.bigquery.storage.v1", 

24 manifest={ 

25 "TableSchema", 

26 "TableFieldSchema", 

27 }, 

28) 

29 

30 

31class TableSchema(proto.Message): 

32 r"""Schema of a table. This schema is a subset of 

33 google.cloud.bigquery.v2.TableSchema containing information 

34 necessary to generate valid message to write to BigQuery. 

35 

36 Attributes: 

37 fields (MutableSequence[google.cloud.bigquery_storage_v1.types.TableFieldSchema]): 

38 Describes the fields in a table. 

39 """ 

40 

41 fields: MutableSequence["TableFieldSchema"] = proto.RepeatedField( 

42 proto.MESSAGE, 

43 number=1, 

44 message="TableFieldSchema", 

45 ) 

46 

47 

48class TableFieldSchema(proto.Message): 

49 r"""TableFieldSchema defines a single field/column within a table 

50 schema. 

51 

52 Attributes: 

53 name (str): 

54 Required. The field name. The name must contain only letters 

55 (a-z, A-Z), numbers (0-9), or underscores (_), and must 

56 start with a letter or underscore. The maximum length is 128 

57 characters. 

58 type_ (google.cloud.bigquery_storage_v1.types.TableFieldSchema.Type): 

59 Required. The field data type. 

60 mode (google.cloud.bigquery_storage_v1.types.TableFieldSchema.Mode): 

61 Optional. The field mode. The default value 

62 is NULLABLE. 

63 fields (MutableSequence[google.cloud.bigquery_storage_v1.types.TableFieldSchema]): 

64 Optional. Describes the nested schema fields 

65 if the type property is set to STRUCT. 

66 description (str): 

67 Optional. The field description. The maximum 

68 length is 1,024 characters. 

69 max_length (int): 

70 Optional. Maximum length of values of this field for STRINGS 

71 or BYTES. 

72 

73 If max_length is not specified, no maximum length constraint 

74 is imposed on this field. 

75 

76 If type = "STRING", then max_length represents the maximum 

77 UTF-8 length of strings in this field. 

78 

79 If type = "BYTES", then max_length represents the maximum 

80 number of bytes in this field. 

81 

82 It is invalid to set this field if type is not "STRING" or 

83 "BYTES". 

84 precision (int): 

85 Optional. Precision (maximum number of total digits in base 

86 10) and scale (maximum number of digits in the fractional 

87 part in base 10) constraints for values of this field for 

88 NUMERIC or BIGNUMERIC. 

89 

90 It is invalid to set precision or scale if type is not 

91 "NUMERIC" or "BIGNUMERIC". 

92 

93 If precision and scale are not specified, no value range 

94 constraint is imposed on this field insofar as values are 

95 permitted by the type. 

96 

97 Values of this NUMERIC or BIGNUMERIC field must be in this 

98 range when: 

99 

100 - Precision (P) and scale (S) are specified: [-10^(P-S) + 

101 10^(-S), 10^(P-S) - 10^(-S)] 

102 - Precision (P) is specified but not scale (and thus scale 

103 is interpreted to be equal to zero): [-10^P + 1, 10^P - 

104 1]. 

105 

106 Acceptable values for precision and scale if both are 

107 specified: 

108 

109 - If type = "NUMERIC": 1 <= precision - scale <= 29 and 0 

110 <= scale <= 9. 

111 - If type = "BIGNUMERIC": 1 <= precision - scale <= 38 and 

112 0 <= scale <= 38. 

113 

114 Acceptable values for precision if only precision is 

115 specified but not scale (and thus scale is interpreted to be 

116 equal to zero): 

117 

118 - If type = "NUMERIC": 1 <= precision <= 29. 

119 - If type = "BIGNUMERIC": 1 <= precision <= 38. 

120 

121 If scale is specified but not precision, then it is invalid. 

122 scale (int): 

123 Optional. See documentation for precision. 

124 default_value_expression (str): 

125 Optional. A SQL expression to specify the [default value] 

126 (https://cloud.google.com/bigquery/docs/default-values) for 

127 this field. 

128 range_element_type (google.cloud.bigquery_storage_v1.types.TableFieldSchema.FieldElementType): 

129 Optional. The subtype of the RANGE, if the type of this 

130 field is RANGE. If the type is RANGE, this field is 

131 required. Possible values for the field element type of a 

132 RANGE include: 

133 

134 - DATE 

135 - DATETIME 

136 - TIMESTAMP 

137 """ 

138 

139 class Type(proto.Enum): 

140 r""" 

141 

142 Values: 

143 TYPE_UNSPECIFIED (0): 

144 Illegal value 

145 STRING (1): 

146 64K, UTF8 

147 INT64 (2): 

148 64-bit signed 

149 DOUBLE (3): 

150 64-bit IEEE floating point 

151 STRUCT (4): 

152 Aggregate type 

153 BYTES (5): 

154 64K, Binary 

155 BOOL (6): 

156 2-valued 

157 TIMESTAMP (7): 

158 64-bit signed usec since UTC epoch 

159 DATE (8): 

160 Civil date - Year, Month, Day 

161 TIME (9): 

162 Civil time - Hour, Minute, Second, 

163 Microseconds 

164 DATETIME (10): 

165 Combination of civil date and civil time 

166 GEOGRAPHY (11): 

167 Geography object 

168 NUMERIC (12): 

169 Numeric value 

170 BIGNUMERIC (13): 

171 BigNumeric value 

172 INTERVAL (14): 

173 Interval 

174 JSON (15): 

175 JSON, String 

176 RANGE (16): 

177 RANGE 

178 """ 

179 TYPE_UNSPECIFIED = 0 

180 STRING = 1 

181 INT64 = 2 

182 DOUBLE = 3 

183 STRUCT = 4 

184 BYTES = 5 

185 BOOL = 6 

186 TIMESTAMP = 7 

187 DATE = 8 

188 TIME = 9 

189 DATETIME = 10 

190 GEOGRAPHY = 11 

191 NUMERIC = 12 

192 BIGNUMERIC = 13 

193 INTERVAL = 14 

194 JSON = 15 

195 RANGE = 16 

196 

197 class Mode(proto.Enum): 

198 r""" 

199 

200 Values: 

201 MODE_UNSPECIFIED (0): 

202 Illegal value 

203 NULLABLE (1): 

204 No description available. 

205 REQUIRED (2): 

206 No description available. 

207 REPEATED (3): 

208 No description available. 

209 """ 

210 MODE_UNSPECIFIED = 0 

211 NULLABLE = 1 

212 REQUIRED = 2 

213 REPEATED = 3 

214 

215 class FieldElementType(proto.Message): 

216 r"""Represents the type of a field element. 

217 

218 Attributes: 

219 type_ (google.cloud.bigquery_storage_v1.types.TableFieldSchema.Type): 

220 Required. The type of a field element. 

221 """ 

222 

223 type_: "TableFieldSchema.Type" = proto.Field( 

224 proto.ENUM, 

225 number=1, 

226 enum="TableFieldSchema.Type", 

227 ) 

228 

229 name: str = proto.Field( 

230 proto.STRING, 

231 number=1, 

232 ) 

233 type_: Type = proto.Field( 

234 proto.ENUM, 

235 number=2, 

236 enum=Type, 

237 ) 

238 mode: Mode = proto.Field( 

239 proto.ENUM, 

240 number=3, 

241 enum=Mode, 

242 ) 

243 fields: MutableSequence["TableFieldSchema"] = proto.RepeatedField( 

244 proto.MESSAGE, 

245 number=4, 

246 message="TableFieldSchema", 

247 ) 

248 description: str = proto.Field( 

249 proto.STRING, 

250 number=6, 

251 ) 

252 max_length: int = proto.Field( 

253 proto.INT64, 

254 number=7, 

255 ) 

256 precision: int = proto.Field( 

257 proto.INT64, 

258 number=8, 

259 ) 

260 scale: int = proto.Field( 

261 proto.INT64, 

262 number=9, 

263 ) 

264 default_value_expression: str = proto.Field( 

265 proto.STRING, 

266 number=10, 

267 ) 

268 range_element_type: FieldElementType = proto.Field( 

269 proto.MESSAGE, 

270 number=11, 

271 message=FieldElementType, 

272 ) 

273 

274 

275__all__ = tuple(sorted(__protobuf__.manifest))