zeroshade commented on code in PR #52330: URL: https://github.com/apache/airflow/pull/52330#discussion_r2175518465
########## providers/apache/arrow/src/airflow/providers/apache/arrow/hooks/adbc.py: ########## @@ -0,0 +1,95 @@ +# +# 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. +from __future__ import annotations + +import functools +from functools import cached_property +from typing import Any + +from adbc_driver_manager.dbapi import connect, Connection + +from airflow.providers.common.sql.hooks.sql import DbApiHook + + +# https://arrow.apache.org/adbc/current/python/api/adbc_driver_manager.html +# https://arrow.apache.org/docs/python/ +class AdbcHook(DbApiHook): + """ + General hook for ADBC access. + """ + + conn_name_attr = "adbc_conn_id" + default_conn_name = "adbc_default" + conn_type = "adbc" + hook_name = "ADBC Connection" + supports_autocommit = True + + @classmethod + def get_ui_field_behaviour(cls) -> dict[str, Any]: + """Get custom field behaviour.""" + return { + "hidden_fields": ["port", "schema"], + "relabeling": {"host": "Connection URL"}, + } + + @functools.lru_cache + def _driver_path(self) -> str | None: + import pathlib + import sys + + import importlib_resources + + driver = self.connection_extra_lower.get("driver") + + if driver: + # Wheels bundle the shared library + root = importlib_resources.files(driver) Review Comment: Currently you would specify the driver to the adbc_driver_manager by providing either a shared lib on the `LD_LIBRARY_PATH` or a full path to the desired dynamic library. Once the manifest stuff is implemented then you'd be able to also provide the name of the manifest to load -- 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]
