dbt-firebolt 1.6.3__tar.gz → 1.7.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/PKG-INFO +1 -1
  2. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/adapters/firebolt/__init__.py +1 -1
  3. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/adapters/firebolt/impl.py +21 -3
  4. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/adapters/firebolt/relation.py +20 -2
  5. dbt_firebolt-1.7.0/dbt/adapters/firebolt/relation_configs/__init__.py +0 -0
  6. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/adapters.sql +10 -95
  7. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/catalog.sql +103 -0
  8. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/dbt_external_tables/create_external_table.sql +137 -0
  9. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/materializations/materialized_view.sql +3 -0
  10. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/materialized_view/alter.sql +11 -0
  11. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/materialized_view/create.sql +3 -0
  12. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/materialized_view/describe.sql +3 -0
  13. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/materialized_view/drop.sql +3 -0
  14. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/materialized_view/refresh.sql +3 -0
  15. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/table/create.sql +74 -0
  16. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/table/drop.sql +3 -0
  17. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/table/rename.sql +6 -0
  18. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/table/replace.sql +3 -0
  19. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/view/create.sql +16 -0
  20. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/view/drop.sql +3 -0
  21. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/view/rename.sql +6 -0
  22. dbt_firebolt-1.7.0/dbt/include/firebolt/macros/relations/view/replace.sql +3 -0
  23. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt_firebolt.egg-info/PKG-INFO +1 -1
  24. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt_firebolt.egg-info/SOURCES.txt +14 -0
  25. dbt_firebolt-1.6.3/dbt/include/firebolt/macros/catalog.sql +0 -33
  26. dbt_firebolt-1.6.3/dbt/include/firebolt/macros/dbt_external_tables/create_external_table.sql +0 -35
  27. dbt_firebolt-1.6.3/dbt/include/firebolt/macros/materializations/materialized_view.sql +0 -48
  28. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/LICENSE +0 -0
  29. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/MANIFEST.in +0 -0
  30. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/README.md +0 -0
  31. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/adapters/firebolt/__version__.py +0 -0
  32. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/adapters/firebolt/column.py +0 -0
  33. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/adapters/firebolt/connections.py +0 -0
  34. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/__init__.py +0 -0
  35. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/dbt_project.yml +0 -0
  36. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/adapters/apply_grants.sql +0 -0
  37. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/adapters/relation.sql +0 -0
  38. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/dbt_external_tables/dropif.sql +0 -0
  39. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/dbt_external_tables/get_external_build_plan.sql +0 -0
  40. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/clone.sql +0 -0
  41. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/models/incremental/column_helpers.sql +0 -0
  42. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/models/incremental/incremental.sql +0 -0
  43. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/models/incremental/is_incremental.sql +0 -0
  44. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/models/incremental/merge.sql +0 -0
  45. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/models/incremental/on_schema_change.sql +0 -0
  46. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/models/incremental/strategies.sql +0 -0
  47. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/seed.sql +0 -0
  48. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/table.sql +0 -0
  49. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/test.sql +0 -0
  50. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/materializations/view.sql +0 -0
  51. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/array_append.sql +0 -0
  52. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/array_concat.sql +0 -0
  53. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/array_construct.sql +0 -0
  54. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/bool_or.sql +0 -0
  55. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/cast_bool_to_text.sql +0 -0
  56. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/dateadd.sql +0 -0
  57. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/datediff.sql +0 -0
  58. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/except.sql +0 -0
  59. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/intersect.sql +0 -0
  60. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/listagg.sql +0 -0
  61. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/position.sql +0 -0
  62. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/right.sql +0 -0
  63. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/split_part.sql +0 -0
  64. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt/include/firebolt/macros/utils/timestamps.sql +0 -0
  65. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt_firebolt.egg-info/dependency_links.txt +0 -0
  66. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt_firebolt.egg-info/requires.txt +0 -0
  67. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/dbt_firebolt.egg-info/top_level.txt +0 -0
  68. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/pyproject.toml +0 -0
  69. {dbt_firebolt-1.6.3 → dbt_firebolt-1.7.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt_firebolt
3
- Version: 1.6.3
3
+ Version: 1.7.0
4
4
  Summary: The Firebolt adapter plugin for dbt (data build tool)
5
5
  Home-page: https://github.com/firebolt-db/dbt-firebolt
6
6
  Author: Firebolt
@@ -7,7 +7,7 @@ from dbt.adapters.firebolt.connections import (
7
7
  from dbt.adapters.firebolt.impl import FireboltAdapter
8
8
  from dbt.include import firebolt
9
9
 
10
- __version__ = "1.6.3"
10
+ __version__ = "1.7.0"
11
11
 
12
12
  Plugin = AdapterPlugin(
13
13
  adapter=FireboltAdapter, # type: ignore
@@ -5,10 +5,17 @@ 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 available
9
- from dbt.adapters.base.impl import AdapterConfig, ConstraintSupport
8
+ from dbt.adapters.base import available # type: ignore
9
+ from dbt.adapters.base.impl import AdapterConfig # type: ignore
10
+ from dbt.adapters.base.impl import ConstraintSupport
10
11
  from dbt.adapters.base.relation import BaseRelation
11
- from dbt.adapters.sql import SQLAdapter
12
+ from dbt.adapters.capability import (
13
+ Capability,
14
+ CapabilityDict,
15
+ CapabilitySupport,
16
+ Support,
17
+ )
18
+ from dbt.adapters.sql import SQLAdapter # type: ignore
12
19
  from dbt.contracts.graph.nodes import ConstraintType
13
20
  from dbt.dataclass_schema import ValidationError, dbtClassMixin
14
21
  from dbt.exceptions import (
@@ -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,7 +1,9 @@
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, Policy
4
+ from dbt.adapters.base import RelationType # type: ignore
5
+ from dbt.adapters.base.relation import BaseRelation, Policy # type: ignore
6
+ from dbt.adapters.relation_configs import RelationConfigBase # type: ignore
5
7
  from dbt.exceptions import DbtRuntimeError
6
8
 
7
9
 
@@ -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:
@@ -168,106 +168,21 @@
168
168
  #}
169
169
  {% call statement('list_tables_without_caching', fetch_result=True) %}
170
170
 
171
- SELECT '{{ relation.database }}' AS "database",
172
- table_name AS "name",
173
- '{{ relation.schema }}' AS "schema",
174
- 'table' AS type
175
- FROM information_schema.tables
176
- UNION ALL
177
- SELECT '{{ relation.database }}' AS "database",
178
- table_name AS "name",
179
- '{{ relation.schema }}' AS "schema",
180
- 'view' AS type
181
- FROM information_schema.views
171
+ SELECT
172
+ table_catalog AS "database",
173
+ table_name AS "name",
174
+ '{{ relation.schema }}' AS "schema",
175
+ CASE
176
+ WHEN table_type = 'VIEW' THEN 'view'
177
+ ELSE 'table'
178
+ END AS "type"
179
+ FROM
180
+ information_schema.tables
182
181
  {% endcall %}
183
182
  {% set info_table = load_result('list_tables_without_caching').table %}
184
183
  {{ return(info_table) }}
185
184
  {% endmacro %}
186
185
 
187
-
188
- {% macro firebolt__create_table_as(temporary,
189
- relation,
190
- select_sql,
191
- language='sql') -%}
192
- {# Create table using CTAS
193
- Args:
194
- temporary (bool): Unused, included so macro signature matches
195
- that of dbt's default macro
196
- relation (dbt relation/dict)
197
- select_sql (string): The SQL query that will be used to generate
198
- the internal query of the CTAS
199
- language (string): sql or python models. Firebolt only supports sql.
200
- #}
201
- {%- if language == 'python' -%}
202
- {{ exceptions.raise_compiler_error("Firebolt does not currently support "
203
- "Python models.") }}
204
- {%- elif language not in ['python', 'sql'] -%}
205
- {{ exceptions.raise_compiler_error("Unexpected language parameter supplied: %s "
206
- "Must be either 'sql' or 'python'." % (language)) }}
207
- {%- endif -%}
208
-
209
- {%- set table_type = config.get('table_type', default='dimension') | upper -%}
210
- {%- set primary_index = config.get('primary_index') -%}
211
- {%- set incremental_strategy = config.get('incremental_strategy') -%}
212
- {%- set partitions = config.get('partition_by') %}
213
-
214
- CREATE {{ table_type }} TABLE IF NOT EXISTS {{ relation }}
215
- {%- set contract_config = config.get('contract') -%}
216
- {%- if contract_config.enforced -%}
217
- {{ get_assert_columns_equivalent(select_sql) }}
218
- {{ get_table_columns_and_constraints() }} ;
219
- insert into {{ relation }} (
220
- {{ adapter.dispatch('get_column_names', 'dbt')() }}
221
- )
222
- {%- set select_sql = get_select_subquery(select_sql) %}
223
- {% endif %}
224
- {%- if primary_index %}
225
- PRIMARY INDEX
226
- {% if primary_index is iterable and primary_index is not string %}
227
- {{ primary_index | join(', ') }}
228
- {%- else -%}
229
- {{ primary_index }}
230
- {%- endif -%}
231
- {%- endif -%}
232
- {% if partitions %}
233
- PARTITION BY
234
- {% if partitions is iterable and partitions is not string %}
235
- {{ partitions | join(', ') }}
236
- {%- else -%}
237
- {{ partitions }}
238
- {%- endif -%}
239
- {%- endif %}
240
- {%- if not contract_config.enforced %}
241
- AS (
242
- {% endif -%}
243
- {{ select_sql }}
244
- {% if not contract_config.enforced -%}
245
- )
246
- {%- endif -%}
247
- {% endmacro %}
248
-
249
-
250
- {% macro firebolt__create_view_as(relation, select_sql) %}
251
- {#-
252
- Return SQL string to create view.
253
- Args:
254
- relation (dict): dbt relation
255
- select_sql (string): The SQL query that will be used to generate
256
- the internal query of the CTAS
257
- #}
258
-
259
- CREATE OR REPLACE VIEW {{ relation.identifier }}
260
-
261
- {%- set contract_config = config.get('contract') -%}
262
- {%- if contract_config.enforced -%}
263
- {{ get_assert_columns_equivalent(select_sql) }}
264
- {%- endif %}
265
- AS (
266
- {{ select_sql }}
267
- )
268
- {% endmacro %}
269
-
270
-
271
186
  {% macro firebolt__truncate_relation(relation) -%}
272
187
  {#
273
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,137 @@
1
+ {% macro firebolt__create_external_table(source_node) %}
2
+ {% if source_node.external.strategy == 'copy' %}
3
+ {{ firebolt__create_with_copy_from(source_node) }}
4
+ {% else %}
5
+ {{ firebolt__create_with_external_table(source_node) }}
6
+ {% endif %}
7
+ {% endmacro %}
8
+
9
+ {% macro firebolt__create_with_external_table(source_node) %}
10
+ {%- set external = source_node.external -%}
11
+ {%- if 'partitions' in external -%}
12
+ {%- set columns = adapter.make_field_partition_pairs(source_node.columns.values(),
13
+ external.partitions) -%}
14
+ {%- else -%}
15
+ {%- set columns = adapter.make_field_partition_pairs(source_node.columns.values(),
16
+ []) -%}
17
+ {%- endif -%}
18
+ {%- set credentials = external.credentials -%}
19
+ {# Leaving out "IF NOT EXISTS" because this should only be called by
20
+ if no DROP IF is necessary. #}
21
+ CREATE EXTERNAL TABLE {{source(source_node.source_name, source_node.name)}} (
22
+ {%- for column in columns -%}
23
+ {{ column }}
24
+ {{- ',' if not loop.last }}
25
+ {% endfor -%}
26
+ )
27
+ {% if external.url %} URL = '{{external.url}}' {%- endif %}
28
+ {%- if credentials and credentials.internal_role_arn %}
29
+ CREDENTIALS = (AWS_ROLE_ARN = '{{credentials.internal_role_arn}}'
30
+ {%- if credentials.external_role_id %}
31
+ AWS_ROLE_EXTERNAL_ID = '{{credentials.external_role_id}}'
32
+ {%- endif -%}
33
+ )
34
+ {% elif credentials and credentials.aws_key_id %}
35
+ CREDENTIALS = (AWS_KEY_ID = '{{credentials.aws_key_id}}'
36
+ AWS_SECRET_KEY = '{{credentials.aws_secret_key}}')
37
+ {%- endif %}
38
+ {%- if external.object_pattern -%} OBJECT_PATTERN = '{{external.object_pattern}}' {%- endif %}
39
+ {% if external.object_patterns -%}
40
+ OBJECT_PATTERN =
41
+ {%- for obj in external.object_patterns -%}
42
+ {{ obj }}
43
+ {{- ',' if not loop.last }}
44
+ {%- endfor %}
45
+ {%- endif %}
46
+ {%- if external.compression -%} COMPRESSION = {{external.compression}} {%- endif %}
47
+ TYPE = {{ external.type }}
48
+ {% endmacro %}
49
+
50
+ {% macro firebolt__create_with_copy_from(source_node) %}
51
+ {# COPY FROM is only available in Firebolt 2.0. #}
52
+ {%- set external = source_node.external -%}
53
+ {%- set credentials = external.credentials -%}
54
+ {%- set options = external.options -%}
55
+ {%- set csv_options = options.csv_options -%}
56
+ {%- set error_file_credentials = options.error_file_credentials -%}
57
+
58
+ {# There are no partitions, but this formats the columns correctly. #}
59
+ {%- if 'partitions' in external -%}
60
+ {%- set columns = adapter.make_field_partition_pairs(source_node.columns.values(),
61
+ external.partitions) -%}
62
+ {%- else -%}
63
+ {%- set columns = adapter.make_field_partition_pairs(source_node.columns.values(),
64
+ []) -%}
65
+ {%- endif -%}
66
+ COPY INTO {{source(source_node.source_name, source_node.name)}}
67
+ {%- if columns and columns | length > 0 %}
68
+ (
69
+ {%- for column in columns -%}
70
+ {{ column.name }}
71
+ {%- if column.default is not none %} DEFAULT {{ column.default }}{% endif %}
72
+ {%- if column.source_column_name is not none %} {{ '$' ~ loop.index0 }}{% endif %}
73
+ {{- ',' if not loop.last }}
74
+ {%- endfor -%}
75
+ )
76
+ {%- endif %}
77
+ FROM '{{external.url}}'
78
+ {%- if options %}
79
+ WITH
80
+ {%- if options.object_pattern %}
81
+ PATTERN = '{{options.object_pattern}}'
82
+ {%- endif %}
83
+ {%- if options.type %}
84
+ TYPE = {{ options.type }}
85
+ {%- endif %}
86
+ {%- if options.auto_create is not none %}
87
+ AUTO_CREATE = {{ options.auto_create | upper }}
88
+ {%- endif %}
89
+ {%- if options.allow_column_mismatch is not none %}
90
+ ALLOW_COLUMN_MISMATCH = {{ options.allow_column_mismatch | upper }}
91
+ {%- endif %}
92
+ {%- if options.error_file %}
93
+ ERROR_FILE = '{{ options.error_file }}'
94
+ {%- endif %}
95
+ {%- if error_file_credentials %}
96
+ ERROR_FILE_CREDENTIALS = (AWS_KEY_ID = '{{ error_file_credentials.aws_key_id }}' AWS_SECRET_KEY = '{{ error_file_credentials.aws_secret_key }}')
97
+ {%- endif %}
98
+ {%- if options.max_errors_per_file %}
99
+ MAX_ERRORS_PER_FILE = {{ options.max_errors_per_file }}
100
+ {%- endif %}
101
+ {%- if csv_options %}
102
+ {%- if csv_options.header is not none %}
103
+ HEADER = {{ csv_options.header | upper }}
104
+ {%- endif %}
105
+ {%- if csv_options.delimiter %}
106
+ DELIMITER = '{{ csv_options.delimiter }}'
107
+ {%- endif %}
108
+ {%- if csv_options.newline %}
109
+ NEWLINE = '{{ csv_options.newline }}'
110
+ {%- endif %}
111
+ {%- if csv_options.quote %}
112
+ QUOTE = {{ csv_options.quote }}
113
+ {%- endif %}
114
+ {%- if csv_options.escape %}
115
+ ESCAPE = '{{ csv_options.escape }}'
116
+ {%- endif %}
117
+ {%- if csv_options.null_string %}
118
+ NULL_STRING = '{{ csv_options.null_string }}'
119
+ {%- endif %}
120
+ {%- if csv_options.empty_field_as_null is not none %}
121
+ EMPTY_FIELD_AS_NULL = {{ csv_options.empty_field_as_null | upper }}
122
+ {%- endif %}
123
+ {%- if csv_options.skip_blank_lines is not none %}
124
+ SKIP_BLANK_LINES = {{ csv_options.skip_blank_lines | upper }}
125
+ {%- endif %}
126
+ {%- if csv_options.date_format %}
127
+ DATE_FORMAT = '{{ csv_options.date_format }}'
128
+ {%- endif %}
129
+ {%- if csv_options.timestamp_format %}
130
+ TIMESTAMP_FORMAT = '{{ csv_options.timestamp_format }}'
131
+ {%- endif %}
132
+ {%- endif %}
133
+ {%- endif %}
134
+ {%- if credentials %}
135
+ CREDENTIALS = (AWS_KEY_ID = '{{credentials.aws_key_id}}' AWS_SECRET_KEY = '{{credentials.aws_secret_key}}')
136
+ {%- endif %}
137
+ {% endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__get_materialized_view_configuration_changes(existing_relation, new_config) %}
2
+ {{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
3
+ {% 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,3 @@
1
+ {% macro firebolt__get_create_materialized_view_as_sql(relation, sql) %}
2
+ {{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
3
+ {% endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro redshift__describe_materialized_view(relation) %}
2
+ {{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
3
+ {% endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__drop_materialized_view(relation) %}
2
+ {{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
3
+ {% endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__refresh_materialized_view(relation) %}
2
+ {{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }}
3
+ {% 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,3 @@
1
+ {%- macro firebolt__drop_table(relation) -%}
2
+ DROP TABLE IF EXISTS {{ relation }} CASCADE
3
+ {%- endmacro -%}
@@ -0,0 +1,6 @@
1
+ {% macro firebolt__get_rename_table_sql(
2
+ relation,
3
+ new_name
4
+ ) %}
5
+ {{ exceptions.raise_compiler_error("Firebolt does not support table renames") }}
6
+ {% endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__get_replace_table_sql(relation, sql) %}
2
+ {{ firebolt__create_table_as(False, relation, sql) }}
3
+ {% 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 %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__get_drop_view_sql(relation) %}
2
+ DROP VIEW if EXISTS {{ relation }} CASCADE
3
+ {% endmacro %}
@@ -0,0 +1,6 @@
1
+ {% macro firebolt__get_rename_view_sql(
2
+ relation,
3
+ new_name
4
+ ) %}
5
+ {{ exceptions.raise_compiler_error("Firebolt does not support view renames") }}
6
+ {% endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__get_replace_view_sql(relation, sql) %}
2
+ {{ firebolt__create_view_as(relation, sql) }}
3
+ {% endmacro %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt-firebolt
3
- Version: 1.6.3
3
+ Version: 1.7.0
4
4
  Summary: The Firebolt adapter plugin for dbt (data build tool)
5
5
  Home-page: https://github.com/firebolt-db/dbt-firebolt
6
6
  Author: Firebolt
@@ -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
@@ -1,33 +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 tbls.table_catalog AS table_database
7
- , tbls.table_schema as table_schema
8
- , table_type
9
- , tbls.table_name as table_name
10
- , cols.column_name as column_name
11
- , cols.data_type AS column_type
12
- , UPPER(tbls.table_type) as relation_type
13
- , cols.ordinal_position as column_index
14
- FROM information_schema.tables tbls
15
- JOIN information_schema.columns cols
16
- USING(table_name)
17
-
18
- UNION ALL
19
-
20
- SELECT views.table_catalog AS table_database
21
- , views.table_schema as table_schema
22
- , 'VIEW' AS table_type
23
- , views.table_name as table_name
24
- , cols.column_name AS column_name
25
- , cols.data_type AS column_type
26
- , 'VIEW' as relation_type
27
- , cols.ordinal_position as column_index
28
- FROM information_schema.views views
29
- JOIN information_schema.columns cols
30
- USING(table_name)
31
- {% endcall -%}
32
- {{ return(load_result('catalog').table) }}
33
- {%- endmacro %}
@@ -1,35 +0,0 @@
1
- {% macro firebolt__create_external_table(source_node) %}
2
- {%- set external = source_node.external -%}
3
- {%- if 'partitions' in external -%}
4
- {%- set columns = adapter.make_field_partition_pairs(source_node.columns.values(),
5
- external.partitions) -%}
6
- {%- else -%}
7
- {%- set columns = adapter.make_field_partition_pairs(source_node.columns.values(),
8
- []) -%}
9
- {%- endif -%}
10
- -- {%- set partitions = external.partitions -%}
11
- {%- set credentials = external.credentials -%}
12
- {# Leaving out "IF NOT EXISTS" because this should only be called by
13
- if no DROP IF is necessary. #}
14
- CREATE EXTERNAL TABLE {{source(source_node.source_name, source_node.name)}} (
15
- {%- for column in columns -%}
16
- {{ column }}
17
- {{- ',' if not loop.last }}
18
- {% endfor -%}
19
- )
20
- {% if external.url %} URL = '{{external.url}}' {%- endif %}
21
- {%- if credentials %}
22
- CREDENTIALS = (AWS_ROLE_ARN = '{{credentials.internal_role_arn}}'
23
- AWS_ROLE_EXTERNAL_ID = '{{credentials.external_role_id}}')
24
- {% endif %}
25
- {%- if external.object_pattern -%} OBJECT_PATTERN = '{{external.object_pattern}}' {%- endif %}
26
- {% if external.object_patterns -%}
27
- OBJECT_PATTERN =
28
- {%- for obj in external.object_patterns -%}
29
- {{ obj }}
30
- {{- ',' if not loop.last }}
31
- {%- endfor %}
32
- {%- endif %}
33
- {%- if external.compression -%} COMPRESSION = {{external.compression}} {%- endif %}
34
- TYPE = {{ external.type }}
35
- {% 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