dbt-altertable 0.2.2__tar.gz → 0.2.4__tar.gz
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.
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/PKG-INFO +5 -2
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/adapters/altertable/__init__.py +5 -0
- dbt_altertable-0.2.4/dbt/adapters/altertable/__version__.py +1 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/adapters/altertable/connections.py +43 -11
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/adapters/altertable/impl.py +7 -0
- dbt_altertable-0.2.4/dbt/adapters/altertable/metricflow.py +22 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/persist_docs.sql +9 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/seed.sql +1 -1
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/pyproject.toml +5 -1
- dbt_altertable-0.2.2/dbt/adapters/altertable/__version__.py +0 -1
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/.gitignore +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/LICENSE +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/README.md +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/__init__.py +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/adapters/altertable/credentials.py +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/__init__.py +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/dbt_project.yml +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/adapters.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/catalog.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/columns.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/snapshot_helper.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/any_value.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/dateadd.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/datediff.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/external_location.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/generate_series.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/lastday.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/listagg.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/splitpart.sql +0 -0
- {dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/upstream.sql +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbt-altertable
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: DBT adapter for Altertable
|
|
5
5
|
Project-URL: Homepage, https://github.com/altertable-ai/dbt-altertable
|
|
6
6
|
Project-URL: Repository, https://github.com/altertable-ai/dbt-altertable
|
|
@@ -22,7 +22,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
22
22
|
Classifier: Topic :: Database
|
|
23
23
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
24
|
Requires-Python: >=3.10
|
|
25
|
-
Requires-Dist: altertable-flightsql>=0.
|
|
25
|
+
Requires-Dist: altertable-flightsql>=0.3.1
|
|
26
26
|
Requires-Dist: dbt-adapters<2.0,>=1.5
|
|
27
27
|
Requires-Dist: dbt-core<2.0,>=1.8
|
|
28
28
|
Requires-Dist: pyarrow>=14
|
|
@@ -30,11 +30,14 @@ Provides-Extra: dev
|
|
|
30
30
|
Requires-Dist: conventional-pre-commit>=4.4; extra == 'dev'
|
|
31
31
|
Requires-Dist: pre-commit>=4.0; extra == 'dev'
|
|
32
32
|
Requires-Dist: pytest-mock>=3.10.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-xdist>=3.7; extra == 'dev'
|
|
33
34
|
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
34
35
|
Requires-Dist: ruff>=0.15.11; extra == 'dev'
|
|
35
36
|
Requires-Dist: ty>=0.0.32; extra == 'dev'
|
|
36
37
|
Provides-Extra: integration
|
|
37
38
|
Requires-Dist: testcontainers>=4.0.0; extra == 'integration'
|
|
39
|
+
Provides-Extra: metricflow
|
|
40
|
+
Requires-Dist: dbt-metricflow>=0.12.0; extra == 'metricflow'
|
|
38
41
|
Description-Content-Type: text/markdown
|
|
39
42
|
|
|
40
43
|
# dbt-altertable
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
|
|
1
3
|
from dbt.adapters.base import AdapterPlugin
|
|
2
4
|
|
|
3
5
|
from dbt.adapters.altertable.credentials import AltertableCredentials
|
|
4
6
|
from dbt.adapters.altertable.impl import AltertableAdapter
|
|
5
7
|
from dbt.include import altertable
|
|
6
8
|
|
|
9
|
+
with contextlib.suppress(ModuleNotFoundError):
|
|
10
|
+
from dbt.adapters.altertable import metricflow as _ # noqa: F401
|
|
11
|
+
|
|
7
12
|
__all__ = ["AltertableAdapter", "AltertableCredentials", "Plugin"]
|
|
8
13
|
|
|
9
14
|
Plugin = AdapterPlugin(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "0.2.4" # x-release-please-version
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import threading
|
|
1
2
|
from collections.abc import Iterator, Mapping, Sequence
|
|
2
3
|
from contextlib import contextmanager
|
|
3
4
|
from datetime import date, datetime
|
|
@@ -265,8 +266,7 @@ class AltertableConnection:
|
|
|
265
266
|
return AltertableCursor(self._client)
|
|
266
267
|
|
|
267
268
|
def close(self) -> None:
|
|
268
|
-
|
|
269
|
-
self._client.close()
|
|
269
|
+
pass
|
|
270
270
|
|
|
271
271
|
def commit(self) -> None:
|
|
272
272
|
"""Commit current transaction (no-op for now as we use auto-commit)."""
|
|
@@ -277,6 +277,9 @@ class AltertableConnection:
|
|
|
277
277
|
|
|
278
278
|
class AltertableConnectionManager(SQLConnectionManager):
|
|
279
279
|
TYPE = "altertable"
|
|
280
|
+
_client_lock: threading.Lock = threading.Lock()
|
|
281
|
+
_shared_client: altertable_flightsql.Client | None = None
|
|
282
|
+
_shared_credentials_key: tuple | None = None
|
|
280
283
|
|
|
281
284
|
@classmethod
|
|
282
285
|
def data_type_code_to_name(cls, type_code: Any) -> str:
|
|
@@ -301,6 +304,23 @@ class AltertableConnectionManager(SQLConnectionManager):
|
|
|
301
304
|
def cancel(self, connection: Connection) -> None:
|
|
302
305
|
logger.debug(f"Attempting to cancel connection: {connection.name}")
|
|
303
306
|
|
|
307
|
+
def begin(self):
|
|
308
|
+
connection = self.get_thread_connection()
|
|
309
|
+
connection.transaction_open = True
|
|
310
|
+
return connection
|
|
311
|
+
|
|
312
|
+
def commit(self):
|
|
313
|
+
connection = self.get_thread_connection()
|
|
314
|
+
connection.transaction_open = False
|
|
315
|
+
return connection
|
|
316
|
+
|
|
317
|
+
def release(self) -> None:
|
|
318
|
+
with self.lock:
|
|
319
|
+
conn = self.get_if_exists()
|
|
320
|
+
if conn is None:
|
|
321
|
+
return
|
|
322
|
+
conn.transaction_open = False
|
|
323
|
+
|
|
304
324
|
@classmethod
|
|
305
325
|
def open(cls, connection: Connection) -> Connection:
|
|
306
326
|
if connection.state == ConnectionState.OPEN:
|
|
@@ -320,16 +340,28 @@ class AltertableConnectionManager(SQLConnectionManager):
|
|
|
320
340
|
|
|
321
341
|
@classmethod
|
|
322
342
|
def _connect_client(cls, credentials: AltertableCredentials) -> "AltertableConnection":
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
343
|
+
key = (
|
|
344
|
+
credentials.username,
|
|
345
|
+
credentials.password,
|
|
346
|
+
credentials.host,
|
|
347
|
+
credentials.port,
|
|
348
|
+
credentials.database,
|
|
349
|
+
credentials.schema,
|
|
350
|
+
credentials.tls,
|
|
331
351
|
)
|
|
332
|
-
|
|
352
|
+
with cls._client_lock:
|
|
353
|
+
if cls._shared_client is None or cls._shared_credentials_key != key:
|
|
354
|
+
cls._shared_client = altertable_flightsql.Client(
|
|
355
|
+
username=credentials.username,
|
|
356
|
+
password=credentials.password,
|
|
357
|
+
catalog=credentials.database,
|
|
358
|
+
schema=credentials.schema,
|
|
359
|
+
host=credentials.host,
|
|
360
|
+
port=credentials.port,
|
|
361
|
+
tls=credentials.tls,
|
|
362
|
+
)
|
|
363
|
+
cls._shared_credentials_key = key
|
|
364
|
+
return AltertableConnection(cls._shared_client)
|
|
333
365
|
|
|
334
366
|
@classmethod
|
|
335
367
|
def get_response(cls, cursor: AltertableCursor) -> AdapterResponse:
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from dbt.adapters.base import available
|
|
1
4
|
from dbt.adapters.sql import SQLAdapter
|
|
2
5
|
|
|
3
6
|
from dbt.adapters.altertable.connections import AltertableConnectionManager
|
|
@@ -9,3 +12,7 @@ class AltertableAdapter(SQLAdapter):
|
|
|
9
12
|
@classmethod
|
|
10
13
|
def date_function(cls) -> str:
|
|
11
14
|
return "now()"
|
|
15
|
+
|
|
16
|
+
@available
|
|
17
|
+
def get_seed_file_path(self, model) -> str:
|
|
18
|
+
return os.path.join(model["root_path"], model["original_file_path"])
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dbt_metricflow.cli.dbt_connectors.adapter_backed_client import AdapterBackedSqlClient
|
|
4
|
+
from metricflow.protocols.sql_client import SqlEngine
|
|
5
|
+
from metricflow.sql.render.duckdb_renderer import DuckDbSqlPlanRenderer
|
|
6
|
+
|
|
7
|
+
# dbt-metricflow only accepts a hardcoded list of 7 adapters and crashes on anything else.
|
|
8
|
+
# This patch intercepts the initialization and tells it to use DuckDB's SQL renderer,
|
|
9
|
+
# since Altertable runs on DuckLake which uses DuckDB SQL dialect.
|
|
10
|
+
_original_init = AdapterBackedSqlClient.__init__
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _patched_init(self, adapter) -> None:
|
|
14
|
+
if adapter.type() == "altertable":
|
|
15
|
+
self._adapter = adapter
|
|
16
|
+
self._sql_engine_type = SqlEngine.DUCKDB
|
|
17
|
+
self._sql_plan_renderer = DuckDbSqlPlanRenderer()
|
|
18
|
+
else:
|
|
19
|
+
_original_init(self, adapter)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
AdapterBackedSqlClient.__init__ = _patched_init # ty: ignore[invalid-assignment]
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/persist_docs.sql
RENAMED
|
@@ -32,6 +32,15 @@
|
|
|
32
32
|
one statement per round-trip; the outer run_query then receives an empty string and skips.
|
|
33
33
|
#}
|
|
34
34
|
{% macro altertable__alter_column_comment(relation, column_dict) -%}
|
|
35
|
+
{# Altertable does not support COMMENT ON COLUMN for views (relation-level COMMENT ON VIEW is supported). #}
|
|
36
|
+
{%- if relation.is_view and column_dict | length > 0 -%}
|
|
37
|
+
{%- do exceptions.raise_compiler_error(
|
|
38
|
+
"The Altertable engine does not support COMMENT ON COLUMN for views (relation-level comments are supported). "
|
|
39
|
+
~ "Disable column persistence for this model with persist_docs: {columns: false}, "
|
|
40
|
+
~ "or remove column description entries from its schema YAML. "
|
|
41
|
+
~ "Relation: " ~ relation.render()
|
|
42
|
+
) -%}
|
|
43
|
+
{%- endif -%}
|
|
35
44
|
{%- set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute="name") | list -%}
|
|
36
45
|
{%- set existing_lower_map = {} -%}
|
|
37
46
|
{%- for col in existing_columns -%}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{% endmacro %}
|
|
9
9
|
|
|
10
10
|
{% macro altertable__load_csv_rows(model, agate_table) %}
|
|
11
|
-
{% if config.get('fast',
|
|
11
|
+
{% if config.get('fast', false) %}
|
|
12
12
|
{% set seed_file_path = adapter.get_seed_file_path(model) %}
|
|
13
13
|
{% set delimiter = config.get('delimiter', ',') %}
|
|
14
14
|
{% set sql %}
|
|
@@ -29,14 +29,18 @@ classifiers = [
|
|
|
29
29
|
dependencies = [
|
|
30
30
|
"dbt-core>=1.8,<2.0",
|
|
31
31
|
"dbt-adapters>=1.5,<2.0",
|
|
32
|
-
"altertable-flightsql>=0.
|
|
32
|
+
"altertable-flightsql>=0.3.1",
|
|
33
33
|
"pyarrow>=14",
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
[project.optional-dependencies]
|
|
37
|
+
metricflow = [
|
|
38
|
+
"dbt-metricflow>=0.12.0",
|
|
39
|
+
]
|
|
37
40
|
dev = [
|
|
38
41
|
"pytest>=7.0.0",
|
|
39
42
|
"pytest-mock>=3.10.0",
|
|
43
|
+
"pytest-xdist>=3.7",
|
|
40
44
|
"ruff>=0.15.11",
|
|
41
45
|
"ty>=0.0.32",
|
|
42
46
|
"pre-commit>=4.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = "0.2.2" # x-release-please-version
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/snapshot_helper.sql
RENAMED
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/any_value.sql
RENAMED
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/dateadd.sql
RENAMED
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/datediff.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/lastday.sql
RENAMED
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/listagg.sql
RENAMED
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/splitpart.sql
RENAMED
|
File without changes
|
{dbt_altertable-0.2.2 → dbt_altertable-0.2.4}/dbt/include/altertable/macros/utils/upstream.sql
RENAMED
|
File without changes
|