atoti-client-directquery-databricks 0.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atoti_client_directquery_databricks-0.9.0.dist-info/METADATA +24 -0
- atoti_client_directquery_databricks-0.9.0.dist-info/RECORD +7 -0
- atoti_client_directquery_databricks-0.9.0.dist-info/WHEEL +4 -0
- atoti_directquery_databricks/__init__.py +4 -0
- atoti_directquery_databricks/connection_config.py +146 -0
- atoti_directquery_databricks/py.typed +0 -0
- atoti_directquery_databricks/table_config.py +19 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: atoti-client-directquery-databricks
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Code to use DirectQuery on Databricks
|
|
5
|
+
Home-page: https://www.atoti.io
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Keywords: atoti,cloud,database,directquery,databricks
|
|
8
|
+
Author: ActiveViam
|
|
9
|
+
Author-email: dev@atoti.io
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: License :: Free To Use But Restricted
|
|
13
|
+
Classifier: License :: Other/Proprietary License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Dist: atoti-client (==0.9.0)
|
|
21
|
+
Requires-Dist: pydantic (>=2.6.0)
|
|
22
|
+
Requires-Dist: typing-extensions (>=4.6.1)
|
|
23
|
+
Project-URL: Bug Tracker, https://github.com/atoti/atoti/issues
|
|
24
|
+
Project-URL: Documentation, https://docs.atoti.io/0.9.0/api/atoti_directquery_databricks.html
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
atoti_directquery_databricks/__init__.py,sha256=FTt0-BKSunvVeYPeoA_YiOeJckNopYvK5taPmNBvTl4,202
|
|
2
|
+
atoti_directquery_databricks/connection_config.py,sha256=UYC3ID1CI8Czy0eNwlhTnWu3ghuM6heU_nywnnOvQhY,5138
|
|
3
|
+
atoti_directquery_databricks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
atoti_directquery_databricks/table_config.py,sha256=7CadjwF-k-7tHYTagkWNDNE4yWF0gkIy94zPxphHZsc,525
|
|
5
|
+
atoti_client_directquery_databricks-0.9.0.dist-info/METADATA,sha256=NgOE75VRsgm_S0JtvzMIymAa01MPiz6Rjhnfs-3iZ0k,994
|
|
6
|
+
atoti_client_directquery_databricks-0.9.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
7
|
+
atoti_client_directquery_databricks-0.9.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
from typing import Literal, final
|
|
2
|
+
|
|
3
|
+
from atoti._pydantic import PYDANTIC_CONFIG as _PYDANTIC_CONFIG
|
|
4
|
+
from atoti.directquery._external_database_connection_config import (
|
|
5
|
+
AutoMultiColumnArrayConversionConfig,
|
|
6
|
+
ExternalDatabaseConnectionConfig,
|
|
7
|
+
PasswordConfig,
|
|
8
|
+
)
|
|
9
|
+
from pydantic.dataclasses import dataclass
|
|
10
|
+
from typing_extensions import override
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@final
|
|
14
|
+
@dataclass(config=_PYDANTIC_CONFIG, frozen=True, kw_only=True)
|
|
15
|
+
class ConnectionConfig(
|
|
16
|
+
ExternalDatabaseConnectionConfig,
|
|
17
|
+
AutoMultiColumnArrayConversionConfig,
|
|
18
|
+
PasswordConfig,
|
|
19
|
+
):
|
|
20
|
+
"""Config to connect to a Databricks database.
|
|
21
|
+
|
|
22
|
+
`To aggregate native Databrick arrays, UDAFs (User Defined Aggregation Functions) provided by ActiveViam must be registered on the cluster <https://docs.activeviam.com/products/atoti/server/6.1-next/docs/directquery/databases/databricks/#vectors-support>`__.
|
|
23
|
+
|
|
24
|
+
Native array aggregation is not supported on SQL warehouses.
|
|
25
|
+
|
|
26
|
+
Example:
|
|
27
|
+
>>> import os
|
|
28
|
+
>>> from atoti_directquery_databricks import ConnectionConfig
|
|
29
|
+
>>> connection_config = ConnectionConfig(
|
|
30
|
+
... url="jdbc:databricks://"
|
|
31
|
+
... + os.environ["DATABRICKS_SERVER_HOSTNAME"]
|
|
32
|
+
... + "/default;"
|
|
33
|
+
... + "transportMode=http;"
|
|
34
|
+
... + "ssl=1;"
|
|
35
|
+
... + "httpPath="
|
|
36
|
+
... + os.environ["DATABRICKS_HTTP_PATH_CLUSTER_RUNTIME_15"]
|
|
37
|
+
... + ";"
|
|
38
|
+
... + "AuthMech=3;"
|
|
39
|
+
... + "UID=token;"
|
|
40
|
+
... + "EnableArrow=0;",
|
|
41
|
+
... password=os.environ["DATABRICKS_AUTH_TOKEN"],
|
|
42
|
+
... )
|
|
43
|
+
>>> external_database = session.connect_to_external_database(connection_config)
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
url: str
|
|
48
|
+
"""The JDBC connection string."""
|
|
49
|
+
|
|
50
|
+
feeding_url: str | None = None
|
|
51
|
+
"""When not ``None``, this JDBC connection string will be used instead of :attr:`url` for the feeding phases."""
|
|
52
|
+
|
|
53
|
+
time_travel: Literal[False, "lax", "strict"] = "strict"
|
|
54
|
+
"""How to use Databricks' time travel feature.
|
|
55
|
+
|
|
56
|
+
Databricks does not support time travel with views, so the options are:
|
|
57
|
+
|
|
58
|
+
* ``False``: tables and views are queried on the latest state of the database.
|
|
59
|
+
* ``"lax"``: tables are queried with time travel but views are queried without it.
|
|
60
|
+
* ``"strict"``: tables are queried with time travel and querying a view raises an error.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
array_sum_agg_function_name: str | None = None
|
|
64
|
+
"""The name (if different from the default) of the UDAF performing :func:`atoti.agg.sum` on native arrays.
|
|
65
|
+
|
|
66
|
+
Note:
|
|
67
|
+
This function must be defined in Databricks and accessible to the role running the queries.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
array_long_agg_function_name: str | None = None
|
|
71
|
+
"""The name (if different from the default) of the UDAF performing :func:`atoti.agg.long` on native arrays.
|
|
72
|
+
|
|
73
|
+
Note:
|
|
74
|
+
This function must be defined in Databricks and accessible to the role running the queries.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
array_short_agg_function_name: str | None = None
|
|
78
|
+
"""The name (if different from the default) of the UDAF performing :func:`atoti.agg.short` on native arrays.
|
|
79
|
+
|
|
80
|
+
Note:
|
|
81
|
+
This function must be defined in Databricks and accessible to the role running the queries.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
array_sum_product_agg_function_name: str | None = None
|
|
85
|
+
"""The name (if different from the default) of the UDAF performing :func:`atoti.agg.sum_product` on native arrays.
|
|
86
|
+
|
|
87
|
+
Note:
|
|
88
|
+
This function must be defined in Databricks and accessible to the role running the queries.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
@override
|
|
93
|
+
def _database_key(self) -> str:
|
|
94
|
+
return "DATABRICKS"
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
@override
|
|
98
|
+
def _options(self) -> dict[str, str]:
|
|
99
|
+
return {
|
|
100
|
+
**super()._options,
|
|
101
|
+
**self._auto_multi_array_conversion_options,
|
|
102
|
+
**(
|
|
103
|
+
{"FEEDING_CONNECTION_STRING": self.feeding_url}
|
|
104
|
+
if self.feeding_url
|
|
105
|
+
else {}
|
|
106
|
+
),
|
|
107
|
+
**(
|
|
108
|
+
{
|
|
109
|
+
"SUM_VECTOR_FUNCTION_NAME": self.array_sum_agg_function_name,
|
|
110
|
+
}
|
|
111
|
+
if self.array_sum_agg_function_name
|
|
112
|
+
else {}
|
|
113
|
+
),
|
|
114
|
+
**(
|
|
115
|
+
{
|
|
116
|
+
"LONG_VECTOR_FUNCTION_NAME": self.array_long_agg_function_name,
|
|
117
|
+
}
|
|
118
|
+
if self.array_long_agg_function_name
|
|
119
|
+
else {}
|
|
120
|
+
),
|
|
121
|
+
**(
|
|
122
|
+
{
|
|
123
|
+
"SHORT_VECTOR_FUNCTION_NAME": self.array_short_agg_function_name,
|
|
124
|
+
}
|
|
125
|
+
if self.array_short_agg_function_name
|
|
126
|
+
else {}
|
|
127
|
+
),
|
|
128
|
+
**(
|
|
129
|
+
{
|
|
130
|
+
"SUM_PRODUCT_VECTOR_FUNCTION_NAME": self.array_sum_product_agg_function_name,
|
|
131
|
+
}
|
|
132
|
+
if self.array_sum_product_agg_function_name
|
|
133
|
+
else {}
|
|
134
|
+
),
|
|
135
|
+
"TIME_TRAVEL": self.time_travel.upper() if self.time_travel else "DISABLED",
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@property
|
|
139
|
+
@override
|
|
140
|
+
def _password(self) -> str | None:
|
|
141
|
+
return self.password
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
@override
|
|
145
|
+
def _url(self) -> str | None:
|
|
146
|
+
return self.url
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import final
|
|
2
|
+
|
|
3
|
+
from atoti._pydantic import PYDANTIC_CONFIG as _PYDANTIC_CONFIG
|
|
4
|
+
from atoti.directquery._external_table_config import (
|
|
5
|
+
ArrayConversionConfig,
|
|
6
|
+
ExternalTableConfig,
|
|
7
|
+
)
|
|
8
|
+
from pydantic.dataclasses import dataclass
|
|
9
|
+
|
|
10
|
+
from .connection_config import ConnectionConfig
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@final
|
|
14
|
+
@dataclass(config=_PYDANTIC_CONFIG, frozen=True, kw_only=True)
|
|
15
|
+
class TableConfig(
|
|
16
|
+
ExternalTableConfig[ConnectionConfig],
|
|
17
|
+
ArrayConversionConfig,
|
|
18
|
+
):
|
|
19
|
+
"""Config passed to :meth:`~atoti.Session.add_external_table`."""
|