-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Tabular provider #23704
Add Tabular provider #23704
Changes from all commits
29e6511
1500bca
4c4b8f7
2c54a52
b5bb2d4
2a62119
fab9403
ce56093
55346f7
1b9fc18
c3f515c
8e783e1
032d765
2bc51e7
5111a5d
bd196be
b529a36
f6e8f07
287bf8c
af93366
b963d20
5c1fa56
7075b91
28a7fa1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ body: | |
- sqlite | ||
- ssh | ||
- tableau | ||
- tabular | ||
- telegram | ||
- trino | ||
- vertica | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.. 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. | ||
|
||
Changelog | ||
--------- | ||
|
||
1.0.0 | ||
..... | ||
|
||
Initial version of the provider. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# 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 typing import Any, Dict, Tuple | ||
|
||
import requests | ||
from requests import HTTPError | ||
|
||
from airflow.hooks.base import BaseHook | ||
|
||
DEFAULT_TABULAR_URL = "https://api.tabulardata.io/ws/v1" | ||
|
||
TOKENS_ENDPOINT = "oauth/tokens" | ||
|
||
|
||
class TabularHook(BaseHook): | ||
""" | ||
This hook acts as a base hook for tabular services. It offers the ability to generate temporary, | ||
short-lived session tokens to use within Airflow submitted jobs. | ||
|
||
:param tabular_conn_id: The :ref:`Tabular connection id<howto/connection:tabular>` | ||
which refers to the information to connect to the Tabular OAuth service. | ||
""" | ||
|
||
conn_name_attr = 'tabular_conn_id' | ||
default_conn_name = "tabular_default" | ||
conn_type = "tabular" | ||
hook_name = "Tabular" | ||
|
||
@staticmethod | ||
def get_ui_field_behaviour() -> Dict[str, Any]: | ||
"""Returns custom field behaviour""" | ||
return { | ||
"hidden_fields": ["schema", "port"], | ||
"relabeling": { | ||
"host": "Base URL", | ||
"login": "Client ID", | ||
"password": "Client Secret", | ||
}, | ||
"placeholders": { | ||
"host": DEFAULT_TABULAR_URL, | ||
"login": "client_id (token credentials auth)", | ||
"password": "secret (token credentials auth)", | ||
}, | ||
} | ||
|
||
def __init__(self, tabular_conn_id: str = default_conn_name) -> None: | ||
super().__init__() | ||
self.conn_id = tabular_conn_id | ||
|
||
def test_connection(self) -> Tuple[bool, str]: | ||
"""Test the Tabular connection.""" | ||
try: | ||
self.get_conn() | ||
return True, "Successfully fetched token from Tabular" | ||
except HTTPError as e: | ||
return False, f"HTTP Error: {e}" | ||
except Exception as e: | ||
return False, str(e) | ||
|
||
def get_conn(self) -> str: | ||
"""Obtain a short-lived access token via a client_id and client_secret.""" | ||
conn = self.get_connection(self.conn_id) | ||
base_url = conn.host if conn.host else DEFAULT_TABULAR_URL | ||
base_url = base_url.rstrip('/') | ||
client_id = conn.login | ||
client_secret = conn.password | ||
headers = {"Content-Type": "application/x-www-form-urlencoded"} | ||
data = {"client_id": client_id, "client_secret": client_secret} | ||
|
||
response = requests.post(f"{base_url}/{TOKENS_ENDPOINT}", data=data, headers=headers) | ||
response.raise_for_status() | ||
|
||
return response.json()["access_token"] | ||
|
||
def get_token_macro(self): | ||
return f'{{{{ conn.{self.conn_id}.get_hook().get_conn() }}}}' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# 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. | ||
|
||
--- | ||
package-name: apache-airflow-providers-tabular | ||
name: Tabular | ||
description: | | ||
`Tabular <https://tabular.io/>`__ | ||
|
||
versions: | ||
- 1.0.0 | ||
|
||
dependencies: | ||
- apache-airflow>=2.2.0 | ||
|
||
integrations: | ||
- integration-name: Tabular | ||
external-doc-url: https://tabular.io/docs/ | ||
logo: /integration-logos/tabular/tabular.jpeg | ||
tags: [software] | ||
|
||
hooks: | ||
- integration-name: Tabular | ||
python-modules: | ||
- airflow.providers.tabular.hooks.tabular | ||
|
||
connection-types: | ||
- hook-class-name: airflow.providers.tabular.hooks.tabular.TabularHook | ||
connection-type: tabular |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
.. 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. | ||
|
||
|
||
Package apache-airflow-providers-tabular | ||
------------------------------------------------------ | ||
|
||
`Tabular <https://tabular.io/>`__ | ||
|
||
|
||
This is detailed commit list of changes for versions provider package: ``tabular``. | ||
For high-level changelog, see :doc:`package information including changelog <index>`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.. Licensed to the Apache Software Foundation (ASF) under one | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we typically want to have a URI example for connection in the doc. Is that right @mik-laj? |
||
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. | ||
|
||
.. _howto/connection:tabular: | ||
|
||
Tabular Connection | ||
================== | ||
|
||
The Tabular connection type enables connection to Tabular to request a short lived token to access the Apache Iceberg tables. This token can be injected as an environment variable, to be used with Trino, Spark, Flink or your favorite query engine that supports Apache Iceberg. | ||
|
||
Default Connection IDs | ||
---------------------- | ||
|
||
Tabular Hook uses the parameter ``tabular_conn_id`` for Connection IDs and the value of the parameter as ``tabular_default`` by default. You can create multiple connections in case you want to switch between environments. | ||
|
||
Configuring the Connection | ||
-------------------------- | ||
Client ID | ||
The Client ID from Tabular | ||
|
||
Client Secret | ||
The Client Secret from Tabular | ||
|
||
Host | ||
Sets the URL to the Tabular environment. By default `https://api.tabulardata.io/ws/v1` |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,77 @@ | ||||||
|
||||||
.. 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. | ||||||
|
||||||
``apache-airflow-providers-tabular`` | ||||||
==================================== | ||||||
|
||||||
Content | ||||||
------- | ||||||
|
||||||
.. toctree:: | ||||||
:maxdepth: 1 | ||||||
:caption: Guides | ||||||
|
||||||
Connection types <connections> | ||||||
|
||||||
.. toctree:: | ||||||
:hidden: | ||||||
:caption: System tests | ||||||
|
||||||
System Tests <_api/tests/system/providers/tabular/index> | ||||||
|
||||||
.. toctree:: | ||||||
:maxdepth: 1 | ||||||
:caption: Resources | ||||||
|
||||||
Example DAGs <https://github.com/apache/airflow/tree/providers-tabular/1.0.0/tests/system/providers/tabular> | ||||||
PyPI Repository <https://pypi.org/project/apache-airflow-providers-tabular/> | ||||||
Installing from sources <installing-providers-from-sources> | ||||||
Python API <_api/airflow/providers/tabular/index> | ||||||
|
||||||
|
||||||
.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME! | ||||||
|
||||||
|
||||||
.. toctree:: | ||||||
:maxdepth: 1 | ||||||
:caption: Commits | ||||||
|
||||||
Detailed list of commits <commits> | ||||||
|
||||||
|
||||||
Package apache-airflow-providers-tabular | ||||||
------------------------------------------------------ | ||||||
|
||||||
`Tabular <https://tabular.io/>`__ | ||||||
|
||||||
|
||||||
Release: 0.0.1 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah.. was to quick :).. @Fokko - mind for a small follow-up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing! |
||||||
|
||||||
Provider package | ||||||
---------------- | ||||||
|
||||||
This is a provider package for ``tabular`` provider. All classes for this provider package | ||||||
are in ``airflow.providers.tabular`` python package. | ||||||
|
||||||
Installation | ||||||
------------ | ||||||
|
||||||
You can install this package on top of an existing Airflow 2.1+ installation via | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The minimum version for providers was bumped to 2.2.0 recently 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed that one, I'll do a follow-up! 👍🏻 |
||||||
``pip install apache-airflow-providers-tabular`` | ||||||
|
||||||
.. include:: ../../airflow/providers/tabular/CHANGELOG.rst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀