harishkrao commented on code in PR #28950: URL: https://github.com/apache/airflow/pull/28950#discussion_r1104101143
########## airflow/providers/databricks/sensors/databricks_sql.py: ########## @@ -0,0 +1,119 @@ +# +# 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 Databricks sensors.""" + +from __future__ import annotations + +from typing import Any, Callable, Sequence + +from airflow.providers.common.sql.hooks.sql import fetch_all_handler +from airflow.providers.databricks.hooks.databricks_sql import DatabricksSqlHook +from airflow.sensors.base import BaseSensorOperator +from airflow.utils.context import Context + + +class DatabricksSqlSensor(BaseSensorOperator): + """Generic SQL sensor for Databricks + + :param databricks_conn_id: connection id from Airflow to databricks, + defaults to DatabricksSqlHook.default_conn_name + :param http_path: Optional string specifying HTTP path of + Databricks SQL Endpoint or cluster.If not specified, it should be either specified + in the Databricks connection's extra parameters, or ``sql_endpoint_name`` must be specified. + :param sql_endpoint_name: Optional name of Databricks SQL Endpoint. + If not specified, ``http_path`` must be provided as described above. + :param session_configuration: An optional dictionary of Spark session parameters. + Defaults to None. If not specified, it could be specified in the + Databricks connection's extra parameters. + :param http_headers: An optional list of (k, v) pairs that will be set as HTTP headers on every request. + :param client_parameters: Additional parameters internal to Databricks SQL Connector parameters. + :param sql: SQL query to be executed. Review Comment: Updated. ########## airflow/providers/databricks/sensors/databricks_sql.py: ########## @@ -0,0 +1,119 @@ +# +# 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 Databricks sensors.""" + +from __future__ import annotations + +from typing import Any, Callable, Sequence + +from airflow.providers.common.sql.hooks.sql import fetch_all_handler +from airflow.providers.databricks.hooks.databricks_sql import DatabricksSqlHook +from airflow.sensors.base import BaseSensorOperator +from airflow.utils.context import Context + + +class DatabricksSqlSensor(BaseSensorOperator): + """Generic SQL sensor for Databricks + + :param databricks_conn_id: connection id from Airflow to databricks, + defaults to DatabricksSqlHook.default_conn_name + :param http_path: Optional string specifying HTTP path of + Databricks SQL Endpoint or cluster.If not specified, it should be either specified + in the Databricks connection's extra parameters, or ``sql_endpoint_name`` must be specified. + :param sql_endpoint_name: Optional name of Databricks SQL Endpoint. + If not specified, ``http_path`` must be provided as described above. + :param session_configuration: An optional dictionary of Spark session parameters. + Defaults to None. If not specified, it could be specified in the + Databricks connection's extra parameters. + :param http_headers: An optional list of (k, v) pairs that will be set as HTTP headers on every request. + :param client_parameters: Additional parameters internal to Databricks SQL Connector parameters. + :param sql: SQL query to be executed. + """ + + template_fields: Sequence[str] = ( + "databricks_conn_id", + "sql", + "_catalog", + "http_headers", + ) + + template_ext: Sequence[str] = (".sql",) + template_fields_renderers = {"sql": "sql"} + + def __init__( + self, + *, + databricks_conn_id: str = DatabricksSqlHook.default_conn_name, + http_path: str | None = None, + sql_endpoint_name: str | None = None, + session_configuration=None, + http_headers: list[tuple[str, str]] | None = None, + catalog: str = "hive_metastore", + schema: str = "default", Review Comment: Fixed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
