Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/cloud/bigquery/__init__.py: 93%

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

102 statements  

1# Copyright 2015 Google LLC 

2# 

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

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

5# You may obtain a copy of the License at 

6# 

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

8# 

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

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

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

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

13# limitations under the License. 

14 

15"""Google BigQuery API wrapper. 

16 

17The main concepts with this API are: 

18 

19- :class:`~google.cloud.bigquery.client.Client` manages connections to the 

20 BigQuery API. Use the client methods to run jobs (such as a 

21 :class:`~google.cloud.bigquery.job.QueryJob` via 

22 :meth:`~google.cloud.bigquery.client.Client.query`) and manage resources. 

23 

24- :class:`~google.cloud.bigquery.dataset.Dataset` represents a 

25 collection of tables. 

26 

27- :class:`~google.cloud.bigquery.table.Table` represents a single "relation". 

28""" 

29 

30import warnings 

31 

32from google.cloud.bigquery import version as bigquery_version 

33 

34__version__ = bigquery_version.__version__ 

35 

36from google.cloud.bigquery.client import Client 

37from google.cloud.bigquery.dataset import AccessEntry 

38from google.cloud.bigquery.dataset import Dataset 

39from google.cloud.bigquery.dataset import DatasetReference 

40from google.cloud.bigquery import enums 

41from google.cloud.bigquery.enums import AutoRowIDs 

42from google.cloud.bigquery.enums import DecimalTargetType 

43from google.cloud.bigquery.enums import KeyResultStatementKind 

44from google.cloud.bigquery.enums import SqlTypeNames 

45from google.cloud.bigquery.enums import StandardSqlTypeNames 

46from google.cloud.bigquery.exceptions import LegacyBigQueryStorageError 

47from google.cloud.bigquery.exceptions import LegacyPandasError 

48from google.cloud.bigquery.exceptions import LegacyPyarrowError 

49from google.cloud.bigquery.external_config import ExternalConfig 

50from google.cloud.bigquery.external_config import BigtableOptions 

51from google.cloud.bigquery.external_config import BigtableColumnFamily 

52from google.cloud.bigquery.external_config import BigtableColumn 

53from google.cloud.bigquery.external_config import CSVOptions 

54from google.cloud.bigquery.external_config import GoogleSheetsOptions 

55from google.cloud.bigquery.external_config import ExternalSourceFormat 

56from google.cloud.bigquery.external_config import HivePartitioningOptions 

57from google.cloud.bigquery.format_options import AvroOptions 

58from google.cloud.bigquery.format_options import ParquetOptions 

59from google.cloud.bigquery.job.base import SessionInfo 

60from google.cloud.bigquery.job import Compression 

61from google.cloud.bigquery.job import CopyJob 

62from google.cloud.bigquery.job import CopyJobConfig 

63from google.cloud.bigquery.job import CreateDisposition 

64from google.cloud.bigquery.job import DestinationFormat 

65from google.cloud.bigquery.job import DmlStats 

66from google.cloud.bigquery.job import Encoding 

67from google.cloud.bigquery.job import ExtractJob 

68from google.cloud.bigquery.job import ExtractJobConfig 

69from google.cloud.bigquery.job import LoadJob 

70from google.cloud.bigquery.job import LoadJobConfig 

71from google.cloud.bigquery.job import OperationType 

72from google.cloud.bigquery.job import QueryJob 

73from google.cloud.bigquery.job import QueryJobConfig 

74from google.cloud.bigquery.job import QueryPriority 

75from google.cloud.bigquery.job import SchemaUpdateOption 

76from google.cloud.bigquery.job import ScriptOptions 

77from google.cloud.bigquery.job import SourceFormat 

78from google.cloud.bigquery.job import UnknownJob 

79from google.cloud.bigquery.job import TransactionInfo 

80from google.cloud.bigquery.job import WriteDisposition 

81from google.cloud.bigquery.model import Model 

82from google.cloud.bigquery.model import ModelReference 

83from google.cloud.bigquery.query import ArrayQueryParameter 

84from google.cloud.bigquery.query import ArrayQueryParameterType 

85from google.cloud.bigquery.query import ConnectionProperty 

86from google.cloud.bigquery.query import ScalarQueryParameter 

87from google.cloud.bigquery.query import ScalarQueryParameterType 

88from google.cloud.bigquery.query import RangeQueryParameter 

89from google.cloud.bigquery.query import RangeQueryParameterType 

90from google.cloud.bigquery.query import SqlParameterScalarTypes 

91from google.cloud.bigquery.query import StructQueryParameter 

92from google.cloud.bigquery.query import StructQueryParameterType 

93from google.cloud.bigquery.query import UDFResource 

94from google.cloud.bigquery.retry import DEFAULT_RETRY 

95from google.cloud.bigquery.routine import DeterminismLevel 

96from google.cloud.bigquery.routine import Routine 

97from google.cloud.bigquery.routine import RoutineArgument 

98from google.cloud.bigquery.routine import RoutineReference 

99from google.cloud.bigquery.routine import RoutineType 

100from google.cloud.bigquery.routine import RemoteFunctionOptions 

101from google.cloud.bigquery.schema import PolicyTagList 

102from google.cloud.bigquery.schema import SchemaField 

103from google.cloud.bigquery.schema import FieldElementType 

104from google.cloud.bigquery.standard_sql import StandardSqlDataType 

105from google.cloud.bigquery.standard_sql import StandardSqlField 

106from google.cloud.bigquery.standard_sql import StandardSqlStructType 

107from google.cloud.bigquery.standard_sql import StandardSqlTableType 

108from google.cloud.bigquery.table import PartitionRange 

109from google.cloud.bigquery.table import RangePartitioning 

110from google.cloud.bigquery.table import Row 

111from google.cloud.bigquery.table import SnapshotDefinition 

112from google.cloud.bigquery.table import CloneDefinition 

113from google.cloud.bigquery.table import Table 

114from google.cloud.bigquery.table import TableReference 

115from google.cloud.bigquery.table import TimePartitioningType 

116from google.cloud.bigquery.table import TimePartitioning 

117from google.cloud.bigquery.encryption_configuration import EncryptionConfiguration 

118from google.cloud.bigquery import _versions_helpers 

119 

120try: 

121 import bigquery_magics # type: ignore 

122except ImportError: 

123 bigquery_magics = None 

124 

125sys_major, sys_minor, sys_micro = _versions_helpers.extract_runtime_version() 

126 

127if sys_major == 3 and sys_minor in (7, 8): 

128 warnings.warn( 

129 "The python-bigquery library no longer supports Python 3.7 " 

130 "and Python 3.8. " 

131 f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We " 

132 "recommend that you update soon to ensure ongoing support. For " 

133 "more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)", 

134 FutureWarning, 

135 ) 

136 

137__all__ = [ 

138 "__version__", 

139 "Client", 

140 # Queries 

141 "ConnectionProperty", 

142 "QueryJob", 

143 "QueryJobConfig", 

144 "ArrayQueryParameter", 

145 "ScalarQueryParameter", 

146 "StructQueryParameter", 

147 "RangeQueryParameter", 

148 "ArrayQueryParameterType", 

149 "ScalarQueryParameterType", 

150 "SqlParameterScalarTypes", 

151 "StructQueryParameterType", 

152 "RangeQueryParameterType", 

153 # Datasets 

154 "Dataset", 

155 "DatasetReference", 

156 "AccessEntry", 

157 # Tables 

158 "Table", 

159 "TableReference", 

160 "PartitionRange", 

161 "RangePartitioning", 

162 "Row", 

163 "SnapshotDefinition", 

164 "CloneDefinition", 

165 "TimePartitioning", 

166 "TimePartitioningType", 

167 # Jobs 

168 "CopyJob", 

169 "CopyJobConfig", 

170 "ExtractJob", 

171 "ExtractJobConfig", 

172 "LoadJob", 

173 "LoadJobConfig", 

174 "SessionInfo", 

175 "UnknownJob", 

176 # Models 

177 "Model", 

178 "ModelReference", 

179 # Routines 

180 "Routine", 

181 "RoutineArgument", 

182 "RoutineReference", 

183 "RemoteFunctionOptions", 

184 # Shared helpers 

185 "SchemaField", 

186 "FieldElementType", 

187 "PolicyTagList", 

188 "UDFResource", 

189 "ExternalConfig", 

190 "AvroOptions", 

191 "BigtableOptions", 

192 "BigtableColumnFamily", 

193 "BigtableColumn", 

194 "DmlStats", 

195 "CSVOptions", 

196 "GoogleSheetsOptions", 

197 "HivePartitioningOptions", 

198 "ParquetOptions", 

199 "ScriptOptions", 

200 "TransactionInfo", 

201 "DEFAULT_RETRY", 

202 # Standard SQL types 

203 "StandardSqlDataType", 

204 "StandardSqlField", 

205 "StandardSqlStructType", 

206 "StandardSqlTableType", 

207 # Enum Constants 

208 "enums", 

209 "AutoRowIDs", 

210 "Compression", 

211 "CreateDisposition", 

212 "DecimalTargetType", 

213 "DestinationFormat", 

214 "DeterminismLevel", 

215 "ExternalSourceFormat", 

216 "Encoding", 

217 "KeyResultStatementKind", 

218 "OperationType", 

219 "QueryPriority", 

220 "RoutineType", 

221 "SchemaUpdateOption", 

222 "SourceFormat", 

223 "SqlTypeNames", 

224 "StandardSqlTypeNames", 

225 "WriteDisposition", 

226 # EncryptionConfiguration 

227 "EncryptionConfiguration", 

228 # Custom exceptions 

229 "LegacyBigQueryStorageError", 

230 "LegacyPyarrowError", 

231 "LegacyPandasError", 

232] 

233 

234 

235def load_ipython_extension(ipython): 

236 """Called by IPython when this module is loaded as an IPython extension.""" 

237 warnings.warn( 

238 "%load_ext google.cloud.bigquery is deprecated. Install bigquery-magics package and use `%load_ext bigquery_magics`, instead.", 

239 category=FutureWarning, 

240 ) 

241 

242 if bigquery_magics is not None: 

243 bigquery_magics.load_ipython_extension(ipython) 

244 else: 

245 from google.cloud.bigquery.magics.magics import _cell_magic 

246 

247 ipython.register_magic_function( 

248 _cell_magic, magic_kind="cell", magic_name="bigquery" 

249 )