dbt-firebolt 1.6.4__tar.gz → 1.8.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/PKG-INFO +1 -1
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/adapters/firebolt/__init__.py +1 -1
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/adapters/firebolt/connections.py +15 -13
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/adapters/firebolt/impl.py +24 -6
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/adapters/firebolt/relation.py +21 -3
- dbt_firebolt-1.8.0/dbt/adapters/firebolt/relation_configs/__init__.py +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/adapters.sql +0 -84
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/catalog.sql +103 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/materializations/materialized_view.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/materialized_view/alter.sql +11 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/materialized_view/create.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/materialized_view/describe.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/materialized_view/drop.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/materialized_view/refresh.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/table/create.sql +74 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/table/drop.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/table/rename.sql +6 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/table/replace.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/view/create.sql +16 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/view/drop.sql +3 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/view/rename.sql +6 -0
- dbt_firebolt-1.8.0/dbt/include/firebolt/macros/relations/view/replace.sql +3 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt_firebolt.egg-info/PKG-INFO +1 -1
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt_firebolt.egg-info/SOURCES.txt +14 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt_firebolt.egg-info/requires.txt +3 -2
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/setup.cfg +3 -2
- dbt_firebolt-1.6.4/dbt/include/firebolt/macros/catalog.sql +0 -23
- dbt_firebolt-1.6.4/dbt/include/firebolt/macros/materializations/materialized_view.sql +0 -48
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/LICENSE +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/MANIFEST.in +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/README.md +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/adapters/firebolt/__version__.py +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/adapters/firebolt/column.py +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/__init__.py +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/dbt_project.yml +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/adapters/apply_grants.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/adapters/relation.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/dbt_external_tables/create_external_table.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/dbt_external_tables/dropif.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/dbt_external_tables/get_external_build_plan.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/clone.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/models/incremental/column_helpers.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/models/incremental/incremental.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/models/incremental/is_incremental.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/models/incremental/merge.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/models/incremental/on_schema_change.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/models/incremental/strategies.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/seed.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/table.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/test.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/view.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/array_append.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/array_concat.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/array_construct.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/bool_or.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/cast_bool_to_text.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/dateadd.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/datediff.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/except.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/intersect.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/listagg.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/position.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/right.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/split_part.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/timestamps.sql +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt_firebolt.egg-info/dependency_links.txt +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt_firebolt.egg-info/top_level.txt +0 -0
- {dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/pyproject.toml +0 -0
@@ -1,19 +1,23 @@
|
|
1
1
|
from contextlib import contextmanager
|
2
2
|
from dataclasses import dataclass
|
3
3
|
from datetime import datetime
|
4
|
+
from multiprocessing.context import SpawnContext
|
4
5
|
from typing import Generator, Optional, Tuple, Union
|
5
6
|
|
6
|
-
|
7
|
-
from dbt.adapters.base import Credentials
|
8
|
-
from dbt.adapters.sql import SQLConnectionManager
|
9
|
-
from dbt.contracts.connection import (
|
7
|
+
from dbt.adapters.contracts.connection import (
|
10
8
|
AdapterRequiredConfig,
|
11
9
|
AdapterResponse,
|
12
10
|
Connection,
|
11
|
+
Credentials,
|
13
12
|
QueryComment,
|
14
13
|
)
|
15
|
-
from dbt.events import AdapterLogger
|
16
|
-
from dbt.
|
14
|
+
from dbt.adapters.events.logging import AdapterLogger
|
15
|
+
from dbt.adapters.sql.connections import SQLConnectionManager
|
16
|
+
from dbt_common.exceptions import (
|
17
|
+
DbtConfigError,
|
18
|
+
DbtRuntimeError,
|
19
|
+
NotImplementedError,
|
20
|
+
)
|
17
21
|
from firebolt.client import DEFAULT_API_URL
|
18
22
|
from firebolt.client.auth import Auth, ClientCredentials, UsernamePassword
|
19
23
|
from firebolt.db import ARRAY, DECIMAL
|
@@ -45,13 +49,13 @@ class FireboltCredentials(Credentials):
|
|
45
49
|
# are provided instead
|
46
50
|
if not self.user and not self.password:
|
47
51
|
if not self.client_id or not self.client_secret:
|
48
|
-
raise
|
52
|
+
raise DbtConfigError(
|
49
53
|
'Either user and password or client_id and client_secret'
|
50
54
|
' must be provided'
|
51
55
|
)
|
52
56
|
else:
|
53
57
|
if self.client_id or self.client_secret:
|
54
|
-
raise
|
58
|
+
raise DbtConfigError(
|
55
59
|
'Either user and password or client_id and client_secret'
|
56
60
|
' must be provided'
|
57
61
|
)
|
@@ -99,13 +103,13 @@ class FireboltConnectionManager(SQLConnectionManager):
|
|
99
103
|
|
100
104
|
TYPE = 'firebolt'
|
101
105
|
|
102
|
-
def __init__(self, profile: AdapterRequiredConfig):
|
106
|
+
def __init__(self, profile: AdapterRequiredConfig, mp_context: SpawnContext):
|
103
107
|
# Query comment in appent mode only
|
104
108
|
# This allows clearer view of queries in query_history
|
105
109
|
if not hasattr(profile, 'query_comment'):
|
106
110
|
setattr(profile, 'query_comment', QueryComment())
|
107
111
|
profile.query_comment.append = True
|
108
|
-
super().__init__(profile)
|
112
|
+
super().__init__(profile, mp_context)
|
109
113
|
|
110
114
|
def __str__(self) -> str:
|
111
115
|
return 'FireboltConnectionManager()'
|
@@ -181,9 +185,7 @@ class FireboltConnectionManager(SQLConnectionManager):
|
|
181
185
|
|
182
186
|
def cancel(self, connection: Connection) -> None:
|
183
187
|
"""Cancel the last query on the given connection."""
|
184
|
-
raise
|
185
|
-
'`cancel` is not implemented for this adapter!'
|
186
|
-
)
|
188
|
+
raise NotImplementedError('`cancel` is not implemented for this adapter!')
|
187
189
|
|
188
190
|
@classmethod
|
189
191
|
def data_type_code_to_name( # type: ignore[override] # FIR-29423
|
@@ -5,13 +5,20 @@ from datetime import datetime
|
|
5
5
|
from typing import Any, List, Mapping, Optional, Union
|
6
6
|
|
7
7
|
import agate
|
8
|
-
from dbt.adapters.base import
|
9
|
-
from dbt.adapters.base.
|
8
|
+
from dbt.adapters.base.impl import ConstraintSupport
|
9
|
+
from dbt.adapters.base.meta import available
|
10
10
|
from dbt.adapters.base.relation import BaseRelation
|
11
|
-
from dbt.adapters.
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
from dbt.adapters.capability import (
|
12
|
+
Capability,
|
13
|
+
CapabilityDict,
|
14
|
+
CapabilitySupport,
|
15
|
+
Support,
|
16
|
+
)
|
17
|
+
from dbt.adapters.protocol import AdapterConfig
|
18
|
+
from dbt.adapters.sql.impl import SQLAdapter
|
19
|
+
from dbt_common.contracts.constraints import ConstraintType
|
20
|
+
from dbt_common.dataclass_schema import ValidationError, dbtClassMixin
|
21
|
+
from dbt_common.exceptions import (
|
15
22
|
CompilationError,
|
16
23
|
DbtRuntimeError,
|
17
24
|
NotImplementedError,
|
@@ -114,6 +121,17 @@ class FireboltAdapter(SQLAdapter):
|
|
114
121
|
ConstraintType.foreign_key: ConstraintSupport.NOT_SUPPORTED,
|
115
122
|
}
|
116
123
|
|
124
|
+
_capabilities: CapabilityDict = CapabilityDict(
|
125
|
+
{
|
126
|
+
Capability.SchemaMetadataByRelations: CapabilitySupport(
|
127
|
+
support=Support.Full
|
128
|
+
),
|
129
|
+
Capability.TableLastModifiedMetadata: CapabilitySupport(
|
130
|
+
support=Support.Unsupported
|
131
|
+
),
|
132
|
+
}
|
133
|
+
)
|
134
|
+
|
117
135
|
@classmethod
|
118
136
|
def is_cancelable(cls) -> bool:
|
119
137
|
return False
|
@@ -1,8 +1,10 @@
|
|
1
1
|
from dataclasses import dataclass, field
|
2
|
-
from typing import Optional
|
2
|
+
from typing import Dict, FrozenSet, Optional
|
3
3
|
|
4
|
-
from dbt.adapters.base.relation import BaseRelation
|
5
|
-
from dbt.
|
4
|
+
from dbt.adapters.base.relation import BaseRelation
|
5
|
+
from dbt.adapters.contracts.relation import Policy, RelationType
|
6
|
+
from dbt.adapters.relation_configs.config_base import RelationConfigBase
|
7
|
+
from dbt_common.exceptions import DbtRuntimeError
|
6
8
|
|
7
9
|
|
8
10
|
@dataclass
|
@@ -30,6 +32,22 @@ class FireboltRelation(BaseRelation):
|
|
30
32
|
quote_character: str = '"'
|
31
33
|
is_delta: Optional[bool] = None
|
32
34
|
information: Optional[str] = None
|
35
|
+
relation_configs: Dict[RelationType, RelationConfigBase] = field(
|
36
|
+
default_factory=lambda: {}
|
37
|
+
)
|
38
|
+
# list relations that can be renamed (e.g. `RENAME my_relation TO my_new_name;`)
|
39
|
+
renameable_relations: FrozenSet[RelationType] = field(
|
40
|
+
default_factory=lambda: frozenset({})
|
41
|
+
)
|
42
|
+
# list relations that can be atomically replaced
|
43
|
+
# (e.g. `CREATE OR REPLACE my_relation..` versus `DROP` and `CREATE`)
|
44
|
+
replaceable_relations: FrozenSet[RelationType] = field(
|
45
|
+
default_factory=lambda: frozenset(
|
46
|
+
{
|
47
|
+
RelationType.View,
|
48
|
+
}
|
49
|
+
)
|
50
|
+
)
|
33
51
|
|
34
52
|
def render(self) -> str:
|
35
53
|
if self.include_policy.database and self.include_policy.schema:
|
File without changes
|
@@ -183,90 +183,6 @@
|
|
183
183
|
{{ return(info_table) }}
|
184
184
|
{% endmacro %}
|
185
185
|
|
186
|
-
|
187
|
-
{% macro firebolt__create_table_as(temporary,
|
188
|
-
relation,
|
189
|
-
select_sql,
|
190
|
-
language='sql') -%}
|
191
|
-
{# Create table using CTAS
|
192
|
-
Args:
|
193
|
-
temporary (bool): Unused, included so macro signature matches
|
194
|
-
that of dbt's default macro
|
195
|
-
relation (dbt relation/dict)
|
196
|
-
select_sql (string): The SQL query that will be used to generate
|
197
|
-
the internal query of the CTAS
|
198
|
-
language (string): sql or python models. Firebolt only supports sql.
|
199
|
-
#}
|
200
|
-
{%- if language == 'python' -%}
|
201
|
-
{{ exceptions.raise_compiler_error("Firebolt does not currently support "
|
202
|
-
"Python models.") }}
|
203
|
-
{%- elif language not in ['python', 'sql'] -%}
|
204
|
-
{{ exceptions.raise_compiler_error("Unexpected language parameter supplied: %s "
|
205
|
-
"Must be either 'sql' or 'python'." % (language)) }}
|
206
|
-
{%- endif -%}
|
207
|
-
|
208
|
-
{%- set table_type = config.get('table_type', default='dimension') | upper -%}
|
209
|
-
{%- set primary_index = config.get('primary_index') -%}
|
210
|
-
{%- set incremental_strategy = config.get('incremental_strategy') -%}
|
211
|
-
{%- set partitions = config.get('partition_by') %}
|
212
|
-
|
213
|
-
CREATE {{ table_type }} TABLE IF NOT EXISTS {{ relation }}
|
214
|
-
{%- set contract_config = config.get('contract') -%}
|
215
|
-
{%- if contract_config.enforced -%}
|
216
|
-
{{ get_assert_columns_equivalent(select_sql) }}
|
217
|
-
{{ get_table_columns_and_constraints() }} ;
|
218
|
-
insert into {{ relation }} (
|
219
|
-
{{ adapter.dispatch('get_column_names', 'dbt')() }}
|
220
|
-
)
|
221
|
-
{%- set select_sql = get_select_subquery(select_sql) %}
|
222
|
-
{% endif %}
|
223
|
-
{%- if primary_index %}
|
224
|
-
PRIMARY INDEX
|
225
|
-
{% if primary_index is iterable and primary_index is not string %}
|
226
|
-
{{ primary_index | join(', ') }}
|
227
|
-
{%- else -%}
|
228
|
-
{{ primary_index }}
|
229
|
-
{%- endif -%}
|
230
|
-
{%- endif -%}
|
231
|
-
{% if partitions %}
|
232
|
-
PARTITION BY
|
233
|
-
{% if partitions is iterable and partitions is not string %}
|
234
|
-
{{ partitions | join(', ') }}
|
235
|
-
{%- else -%}
|
236
|
-
{{ partitions }}
|
237
|
-
{%- endif -%}
|
238
|
-
{%- endif %}
|
239
|
-
{%- if not contract_config.enforced %}
|
240
|
-
AS (
|
241
|
-
{% endif -%}
|
242
|
-
{{ select_sql }}
|
243
|
-
{% if not contract_config.enforced -%}
|
244
|
-
)
|
245
|
-
{%- endif -%}
|
246
|
-
{% endmacro %}
|
247
|
-
|
248
|
-
|
249
|
-
{% macro firebolt__create_view_as(relation, select_sql) %}
|
250
|
-
{#-
|
251
|
-
Return SQL string to create view.
|
252
|
-
Args:
|
253
|
-
relation (dict): dbt relation
|
254
|
-
select_sql (string): The SQL query that will be used to generate
|
255
|
-
the internal query of the CTAS
|
256
|
-
#}
|
257
|
-
|
258
|
-
CREATE OR REPLACE VIEW {{ relation.identifier }}
|
259
|
-
|
260
|
-
{%- set contract_config = config.get('contract') -%}
|
261
|
-
{%- if contract_config.enforced -%}
|
262
|
-
{{ get_assert_columns_equivalent(select_sql) }}
|
263
|
-
{%- endif %}
|
264
|
-
AS (
|
265
|
-
{{ select_sql }}
|
266
|
-
)
|
267
|
-
{% endmacro %}
|
268
|
-
|
269
|
-
|
270
186
|
{% macro firebolt__truncate_relation(relation) -%}
|
271
187
|
{#
|
272
188
|
Truncate relation. Actual macro is drop_relation in ./adapters/relation.sql.
|
@@ -0,0 +1,103 @@
|
|
1
|
+
{# This is for building docs. Right now it's an incomplete description of
|
2
|
+
the columns (for instance, `is_nullable` is missing) but more could be added later. #}
|
3
|
+
|
4
|
+
{% macro firebolt__get_catalog(information_schema, schemas) -%}
|
5
|
+
|
6
|
+
{% set query %}
|
7
|
+
with tables as (
|
8
|
+
{{ firebolt__get_catalog_tables_sql(information_schema) }}
|
9
|
+
{{ firebolt__get_catalog_schemas_where_clause_sql(schemas) }}
|
10
|
+
),
|
11
|
+
columns as (
|
12
|
+
{{ firebolt__get_catalog_columns_sql(information_schema) }}
|
13
|
+
{{ firebolt__get_catalog_schemas_where_clause_sql(schemas) }}
|
14
|
+
)
|
15
|
+
{{ firebolt__get_catalog_results_sql() }}
|
16
|
+
{%- endset -%}
|
17
|
+
|
18
|
+
{{ return(run_query(query)) }}
|
19
|
+
|
20
|
+
{%- endmacro %}
|
21
|
+
|
22
|
+
{% macro firebolt__get_catalog_relations(information_schema, relations) -%}
|
23
|
+
|
24
|
+
{% set query %}
|
25
|
+
with tables as (
|
26
|
+
{{ firebolt__get_catalog_tables_sql(information_schema) }}
|
27
|
+
{{ firebolt__get_catalog_relations_where_clause_sql(relations) }}
|
28
|
+
),
|
29
|
+
columns as (
|
30
|
+
{{ firebolt__get_catalog_columns_sql(information_schema) }}
|
31
|
+
{{ firebolt__get_catalog_relations_where_clause_sql(relations) }}
|
32
|
+
)
|
33
|
+
{{ firebolt__get_catalog_results_sql() }}
|
34
|
+
{%- endset -%}
|
35
|
+
|
36
|
+
{{ return(run_query(query)) }}
|
37
|
+
|
38
|
+
{%- endmacro %}
|
39
|
+
|
40
|
+
|
41
|
+
{% macro firebolt__get_catalog_tables_sql(information_schema) -%}
|
42
|
+
SELECT
|
43
|
+
tbls.table_catalog AS table_database,
|
44
|
+
tbls.table_schema as table_schema,
|
45
|
+
table_type,
|
46
|
+
tbls.table_name as table_name,
|
47
|
+
CASE
|
48
|
+
WHEN table_type = 'VIEW' THEN 'VIEW'
|
49
|
+
ELSE 'TABLE'
|
50
|
+
END AS relation_type
|
51
|
+
FROM
|
52
|
+
information_schema.tables tbls
|
53
|
+
{%- endmacro %}
|
54
|
+
|
55
|
+
|
56
|
+
{% macro firebolt__get_catalog_columns_sql(information_schema) -%}
|
57
|
+
select
|
58
|
+
table_catalog as "table_database",
|
59
|
+
table_schema as "table_schema",
|
60
|
+
table_name as "table_name",
|
61
|
+
column_name as "column_name",
|
62
|
+
ordinal_position as "column_index",
|
63
|
+
data_type as "column_type"
|
64
|
+
from information_schema.columns
|
65
|
+
{%- endmacro %}
|
66
|
+
|
67
|
+
{% macro firebolt__get_catalog_results_sql() -%}
|
68
|
+
SELECT *
|
69
|
+
FROM tables
|
70
|
+
JOIN columns USING ("table_database", "table_schema", "table_name")
|
71
|
+
ORDER BY "column_index"
|
72
|
+
{%- endmacro %}
|
73
|
+
|
74
|
+
|
75
|
+
{% macro firebolt__get_catalog_schemas_where_clause_sql(schemas) -%}
|
76
|
+
WHERE ({%- for schema in schemas -%}
|
77
|
+
UPPER("table_schema") = UPPER('{{ schema }}'){%- if not loop.last %} OR {% endif -%}
|
78
|
+
{%- endfor -%})
|
79
|
+
{%- endmacro %}
|
80
|
+
|
81
|
+
|
82
|
+
{% macro firebolt__get_catalog_relations_where_clause_sql(relations) -%}
|
83
|
+
WHERE (
|
84
|
+
{%- for relation in relations -%}
|
85
|
+
{% if relation.schema and relation.identifier %}
|
86
|
+
(
|
87
|
+
UPPER("table_schema") = UPPER('{{ relation.schema }}')
|
88
|
+
AND UPPER("table_name") = UPPER('{{ relation.identifier }}')
|
89
|
+
)
|
90
|
+
{% elif relation.schema %}
|
91
|
+
(
|
92
|
+
UPPER("table_schema") = UPPER('{{ relation.schema }}')
|
93
|
+
)
|
94
|
+
{% else %}
|
95
|
+
{% do exceptions.raise_compiler_error(
|
96
|
+
'`get_catalog_relations` requires a list of relations, each with a schema'
|
97
|
+
) %}
|
98
|
+
{% endif %}
|
99
|
+
|
100
|
+
{%- if not loop.last %} OR {% endif -%}
|
101
|
+
{%- endfor -%}
|
102
|
+
)
|
103
|
+
{%- endmacro %}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{% macro firebolt__get_alter_materialized_view_as_sql(
|
2
|
+
relation,
|
3
|
+
configuration_changes,
|
4
|
+
sql,
|
5
|
+
existing_relation,
|
6
|
+
backup_relation,
|
7
|
+
intermediate_relation
|
8
|
+
) %}
|
9
|
+
|
10
|
+
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
11
|
+
{% endmacro %}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
{% macro firebolt__create_table_as(
|
2
|
+
temporary,
|
3
|
+
relation,
|
4
|
+
select_sql,
|
5
|
+
language = 'sql'
|
6
|
+
) -%}
|
7
|
+
{# Create table using CTAS
|
8
|
+
Args:
|
9
|
+
temporary (bool): Unused, included so macro signature matches
|
10
|
+
that of dbt's default macro
|
11
|
+
relation (dbt relation/dict)
|
12
|
+
select_sql (string): The SQL query that will be used to generate
|
13
|
+
the internal query of the CTAS
|
14
|
+
language (string): sql or python models. Firebolt only supports sql.
|
15
|
+
#}
|
16
|
+
{%- if language == 'python' -%}
|
17
|
+
{{ exceptions.raise_compiler_error(
|
18
|
+
"Firebolt does not currently support " "Python models."
|
19
|
+
) }}
|
20
|
+
|
21
|
+
{%- elif language not in ['python', 'sql'] -%}
|
22
|
+
{{ exceptions.raise_compiler_error(
|
23
|
+
"Unexpected language parameter supplied: %s " "Must be either 'sql' or 'python'." % (language)
|
24
|
+
) }}
|
25
|
+
{%- endif -%}
|
26
|
+
|
27
|
+
{%- set table_type = config.get(
|
28
|
+
'table_type',
|
29
|
+
default = 'dimension'
|
30
|
+
) | upper -%}
|
31
|
+
{%- set primary_index = config.get('primary_index') -%}
|
32
|
+
{%- set incremental_strategy = config.get('incremental_strategy') -%}
|
33
|
+
{%- set partitions = config.get('partition_by') %}
|
34
|
+
CREATE {{ table_type }} TABLE IF NOT EXISTS {{ relation }}
|
35
|
+
|
36
|
+
{%- set contract_config = config.get('contract') -%}
|
37
|
+
{%- if contract_config.enforced -%}
|
38
|
+
{{ get_assert_columns_equivalent(select_sql) }}
|
39
|
+
{{ get_table_columns_and_constraints() }};
|
40
|
+
INSERT INTO
|
41
|
+
{{ relation }}
|
42
|
+
(
|
43
|
+
{{ adapter.dispatch(
|
44
|
+
'get_column_names',
|
45
|
+
'dbt'
|
46
|
+
)() }}
|
47
|
+
) {%- set select_sql = get_select_subquery(select_sql) %}
|
48
|
+
{% endif %}
|
49
|
+
|
50
|
+
{%- if primary_index %}
|
51
|
+
primary INDEX {% if primary_index is iterable and primary_index is not string %}
|
52
|
+
{{ primary_index | join(', ') }}
|
53
|
+
{%- else -%}
|
54
|
+
{{ primary_index }}
|
55
|
+
{%- endif -%}
|
56
|
+
{%- endif -%}
|
57
|
+
|
58
|
+
{% if partitions %}
|
59
|
+
PARTITION BY {% if partitions is iterable and partitions is not string %}
|
60
|
+
{{ partitions | join(', ') }}
|
61
|
+
{%- else -%}
|
62
|
+
{{ partitions }}
|
63
|
+
{%- endif -%}
|
64
|
+
{%- endif %}
|
65
|
+
|
66
|
+
{%- if not contract_config.enforced %}
|
67
|
+
AS (
|
68
|
+
{% endif -%}
|
69
|
+
|
70
|
+
{{ select_sql }}
|
71
|
+
|
72
|
+
{% if not contract_config.enforced -%})
|
73
|
+
{%- endif -%}
|
74
|
+
{% endmacro %}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{% macro firebolt__create_view_as(
|
2
|
+
relation,
|
3
|
+
select_sql
|
4
|
+
) %}
|
5
|
+
CREATE
|
6
|
+
OR REPLACE VIEW {{ relation.identifier }}
|
7
|
+
|
8
|
+
{%- set contract_config = config.get('contract') -%}
|
9
|
+
{%- if contract_config.enforced -%}
|
10
|
+
{{ get_assert_columns_equivalent(select_sql) }}
|
11
|
+
{%- endif %}
|
12
|
+
|
13
|
+
AS (
|
14
|
+
{{ select_sql }}
|
15
|
+
)
|
16
|
+
{% endmacro %}
|
@@ -9,6 +9,7 @@ setup.cfg
|
|
9
9
|
./dbt/adapters/firebolt/connections.py
|
10
10
|
./dbt/adapters/firebolt/impl.py
|
11
11
|
./dbt/adapters/firebolt/relation.py
|
12
|
+
./dbt/adapters/firebolt/relation_configs/__init__.py
|
12
13
|
./dbt/include/firebolt/__init__.py
|
13
14
|
./dbt/include/firebolt/dbt_project.yml
|
14
15
|
./dbt/include/firebolt/macros/adapters.sql
|
@@ -30,6 +31,19 @@ setup.cfg
|
|
30
31
|
./dbt/include/firebolt/macros/materializations/models/incremental/merge.sql
|
31
32
|
./dbt/include/firebolt/macros/materializations/models/incremental/on_schema_change.sql
|
32
33
|
./dbt/include/firebolt/macros/materializations/models/incremental/strategies.sql
|
34
|
+
./dbt/include/firebolt/macros/relations/materialized_view/alter.sql
|
35
|
+
./dbt/include/firebolt/macros/relations/materialized_view/create.sql
|
36
|
+
./dbt/include/firebolt/macros/relations/materialized_view/describe.sql
|
37
|
+
./dbt/include/firebolt/macros/relations/materialized_view/drop.sql
|
38
|
+
./dbt/include/firebolt/macros/relations/materialized_view/refresh.sql
|
39
|
+
./dbt/include/firebolt/macros/relations/table/create.sql
|
40
|
+
./dbt/include/firebolt/macros/relations/table/drop.sql
|
41
|
+
./dbt/include/firebolt/macros/relations/table/rename.sql
|
42
|
+
./dbt/include/firebolt/macros/relations/table/replace.sql
|
43
|
+
./dbt/include/firebolt/macros/relations/view/create.sql
|
44
|
+
./dbt/include/firebolt/macros/relations/view/drop.sql
|
45
|
+
./dbt/include/firebolt/macros/relations/view/rename.sql
|
46
|
+
./dbt/include/firebolt/macros/relations/view/replace.sql
|
33
47
|
./dbt/include/firebolt/macros/utils/array_append.sql
|
34
48
|
./dbt/include/firebolt/macros/utils/array_concat.sql
|
35
49
|
./dbt/include/firebolt/macros/utils/array_construct.sql
|
@@ -22,8 +22,9 @@ project_urls =
|
|
22
22
|
[options]
|
23
23
|
packages = find_namespace:
|
24
24
|
install_requires =
|
25
|
-
dbt-
|
26
|
-
|
25
|
+
dbt-adapters>=1.0,<2.0
|
26
|
+
dbt-core>=1.8.0
|
27
|
+
firebolt-sdk>=1.5.0
|
27
28
|
pydantic>=0.23
|
28
29
|
python_requires = >=3.8
|
29
30
|
include_package_data = True
|
@@ -1,23 +0,0 @@
|
|
1
|
-
{# This is for building docs. Right now it's an incomplete description of
|
2
|
-
the columns (for instance, `is_nullable` is missing) but more could be added later. #}
|
3
|
-
|
4
|
-
{% macro firebolt__get_catalog(information_schemas, schemas) -%}
|
5
|
-
{%- call statement('catalog', fetch_result=True) %}
|
6
|
-
SELECT
|
7
|
-
tbls.table_catalog AS table_database,
|
8
|
-
tbls.table_schema as table_schema,
|
9
|
-
table_type,
|
10
|
-
tbls.table_name as table_name,
|
11
|
-
cols.column_name as column_name,
|
12
|
-
cols.data_type AS column_type,
|
13
|
-
CASE
|
14
|
-
WHEN table_type = 'VIEW' THEN 'VIEW'
|
15
|
-
ELSE 'TABLE'
|
16
|
-
END AS relation_type,
|
17
|
-
cols.ordinal_position as column_index
|
18
|
-
FROM
|
19
|
-
information_schema.tables tbls
|
20
|
-
JOIN information_schema.columns cols USING (table_name)
|
21
|
-
{% endcall -%}
|
22
|
-
{{ return(load_result('catalog').table) }}
|
23
|
-
{%- endmacro %}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
{#
|
2
|
-
All these macros are stubbed with compiler errors because Firebolt does not
|
3
|
-
support materialized views.
|
4
|
-
#}
|
5
|
-
{% materialization materialized_view, adapter='firebolt' %}
|
6
|
-
|
7
|
-
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
8
|
-
|
9
|
-
{% endmaterialization %}
|
10
|
-
|
11
|
-
{% macro firebolt__get_alter_materialized_view_as_sql(
|
12
|
-
relation,
|
13
|
-
configuration_changes,
|
14
|
-
sql,
|
15
|
-
existing_relation,
|
16
|
-
backup_relation,
|
17
|
-
intermediate_relation
|
18
|
-
) %}
|
19
|
-
|
20
|
-
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
21
|
-
{% endmacro %}
|
22
|
-
|
23
|
-
|
24
|
-
{% macro firebolt__get_create_materialized_view_as_sql(relation, sql) %}
|
25
|
-
|
26
|
-
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
27
|
-
|
28
|
-
{% endmacro %}
|
29
|
-
|
30
|
-
|
31
|
-
{% macro firebolt__get_replace_materialized_view_as_sql(relation, sql, existing_relation, backup_relation, intermediate_relation) %}
|
32
|
-
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
33
|
-
{% endmacro %}
|
34
|
-
|
35
|
-
|
36
|
-
{% macro firebolt__get_materialized_view_configuration_changes(existing_relation, new_config) %}
|
37
|
-
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
38
|
-
{% endmacro %}
|
39
|
-
|
40
|
-
|
41
|
-
{% macro firebolt__refresh_materialized_view(relation) -%}
|
42
|
-
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
43
|
-
{% endmacro %}
|
44
|
-
|
45
|
-
|
46
|
-
{% macro firebolt__drop_materialized_view(relation) -%}
|
47
|
-
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
|
48
|
-
{%- endmacro %}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/adapters/apply_grants.sql
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/dbt_external_tables/dropif.sql
RENAMED
File without changes
|
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/clone.sql
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/seed.sql
RENAMED
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/table.sql
RENAMED
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/test.sql
RENAMED
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/materializations/view.sql
RENAMED
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/array_append.sql
RENAMED
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/array_concat.sql
RENAMED
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/array_construct.sql
RENAMED
File without changes
|
File without changes
|
{dbt_firebolt-1.6.4 → dbt_firebolt-1.8.0}/dbt/include/firebolt/macros/utils/cast_bool_to_text.sql
RENAMED
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
|
File without changes
|
File without changes
|
File without changes
|