Source code for airflow.providers.google.cloud.transfers.bigquery_to_mssql
## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The ASF licenses this file# to you under the Apache License, Version 2.0 (the# "License"); you may not use this file except in compliance# with the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing,# software distributed under the License is distributed on an# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License."""This module contains Google BigQuery to MSSQL operator."""from__future__importannotationsimportwarningsfromtypingimportTYPE_CHECKING,Sequencefromairflow.exceptionsimportAirflowProviderDeprecationWarningfromairflow.providers.google.cloud.links.bigqueryimportBigQueryTableLinkfromairflow.providers.google.cloud.transfers.bigquery_to_sqlimportBigQueryToSqlBaseOperatorfromairflow.providers.microsoft.mssql.hooks.mssqlimportMsSqlHookifTYPE_CHECKING:fromairflow.utils.contextimportContext
[docs]classBigQueryToMsSqlOperator(BigQueryToSqlBaseOperator):""" Fetch data from a BigQuery table (alternatively fetch selected columns) and insert it into a MSSQL table. .. seealso:: For more information on how to use this operator, take a look at the guide: :ref:`howto/operator:BigQueryToMsSqlOperator` :param source_project_dataset_table: A dotted ``<project>.<dataset>.<table>``: the big query table of origin :param mssql_table: target MsSQL table. It is deprecated: use target_table_name instead. (templated) :param target_table_name: target MsSQL table. It takes precedence over mssql_table. (templated) :param mssql_conn_id: reference to a specific mssql hook """
def__init__(self,*,source_project_dataset_table:str,mssql_table:str|None=None,target_table_name:str|None=None,mssql_conn_id:str="mssql_default",**kwargs,)->None:ifmssql_tableisnotNone:warnings.warn("The `mssql_table` parameter has been deprecated. Use `target_table_name` instead.",AirflowProviderDeprecationWarning,stacklevel=2,)iftarget_table_nameisnotNone:raiseValueError(f"Cannot set both arguments: mssql_table={mssql_table!r} and "f"target_table_name={target_table_name!r}.")target_table_name=mssql_tabletry:_,dataset_id,table_id=source_project_dataset_table.split(".")exceptValueError:raiseValueError(f"Could not parse {source_project_dataset_table} as <project>.<dataset>.<table>")fromNonesuper().__init__(target_table_name=target_table_name,dataset_table=f"{dataset_id}.{table_id}",**kwargs,)self.mssql_conn_id=mssql_conn_idself.source_project_dataset_table=source_project_dataset_table