dbt-firebolt 1.9.2__py3-none-any.whl → 1.9.3__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.
- dbt/adapters/firebolt/__init__.py +1 -1
- dbt/include/firebolt/dbt_project.yml +6 -0
- dbt/include/firebolt/macros/adapters.sql +199 -0
- dbt/include/firebolt/macros/catalog.sql +103 -0
- {dbt_firebolt-1.9.2.dist-info → dbt_firebolt-1.9.3.dist-info}/METADATA +1 -1
- dbt_firebolt-1.9.3.dist-info/RECORD +16 -0
- {dbt_firebolt-1.9.2.dist-info → dbt_firebolt-1.9.3.dist-info}/WHEEL +1 -1
- dbt_firebolt-1.9.2.dist-info/RECORD +0 -13
- {dbt_firebolt-1.9.2.dist-info → dbt_firebolt-1.9.3.dist-info}/LICENSE +0 -0
- {dbt_firebolt-1.9.2.dist-info → dbt_firebolt-1.9.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,199 @@
|
|
1
|
+
{% macro firebolt__drop_schema(schema_relation) -%}
|
2
|
+
{# Drop tables and views for schema_relation.
|
3
|
+
Args:
|
4
|
+
schema_relation (dict): Contains values for database and schema.
|
5
|
+
Until schemas are supported this macro will drop all tables and views.
|
6
|
+
#}
|
7
|
+
{% set all_relations = (list_relations_without_caching(schema_relation)) %}
|
8
|
+
|
9
|
+
{% set views = adapter.filter_table(all_relations, 'type', 'view') %}
|
10
|
+
{% set tables = adapter.filter_table(all_relations, 'type', 'table') %}
|
11
|
+
{% do drop_relations_loop(views) %}
|
12
|
+
{% do drop_relations_loop(tables) %}
|
13
|
+
{% endmacro %}
|
14
|
+
|
15
|
+
|
16
|
+
{% macro drop_relations_loop(relations) %}
|
17
|
+
{% for row in relations %}
|
18
|
+
{%- set relation = api.Relation.create(database=target.database,
|
19
|
+
schema=target.schema,
|
20
|
+
identifier=row[1],
|
21
|
+
type=row[3]) -%}
|
22
|
+
{{ adapter.drop_relation(relation) }}
|
23
|
+
{%- endfor %}
|
24
|
+
{% endmacro %}
|
25
|
+
|
26
|
+
|
27
|
+
{% macro firebolt__list_schemas(database) %}
|
28
|
+
{# Return current schema. Name is a misnomer.
|
29
|
+
TODO: Should this actually return all schemas? #}
|
30
|
+
{% call statement('list_schemas', fetch_result=True, auto_begin=False) %}
|
31
|
+
|
32
|
+
SELECT 'public' AS schema
|
33
|
+
{% endcall %}
|
34
|
+
{{ return(load_result('list_schemas').table) }}
|
35
|
+
{% endmacro %}
|
36
|
+
|
37
|
+
|
38
|
+
{% macro firebolt__create_schema(relation) -%}
|
39
|
+
{# stub. Not yet supported in Firebolt. #}
|
40
|
+
{%- call statement('create_schema') %}
|
41
|
+
|
42
|
+
SELECT 'create_schema'
|
43
|
+
{% endcall %}
|
44
|
+
{% endmacro %}
|
45
|
+
|
46
|
+
|
47
|
+
{% macro firebolt__alter_column_type(relation, column_name, new_column_type) -%}
|
48
|
+
{# Stub: alter statements not currently available in Firebolt. #}
|
49
|
+
{% call statement('alter_column_type') %}
|
50
|
+
|
51
|
+
SELECT 'alter_column_type'
|
52
|
+
{% endcall %}
|
53
|
+
{% endmacro %}
|
54
|
+
|
55
|
+
|
56
|
+
{% macro firebolt__check_schema_exists(information_schema, schema) -%}
|
57
|
+
{# Stub. Will be replaced by query later. #}
|
58
|
+
{% call statement('check_schema_exists', fetch_result=True, auto_begin=True) %}
|
59
|
+
|
60
|
+
SELECT 'schema_exists'
|
61
|
+
{% endcall %}
|
62
|
+
{{ return(load_result('check_schema_exists').table) }}
|
63
|
+
{% endmacro %}
|
64
|
+
|
65
|
+
|
66
|
+
{% macro make_create_index_sql(relation,
|
67
|
+
index_name,
|
68
|
+
create_statement,
|
69
|
+
spine_col,
|
70
|
+
other_col) -%}
|
71
|
+
{# Create and return SQL for generating a join or aggregating index.
|
72
|
+
Args:
|
73
|
+
relation (dict):
|
74
|
+
index_name (str): name of the index
|
75
|
+
create_statement (str): either "CREATE JOIN INDEX" or
|
76
|
+
"CREATE AND GENERATE AGGREGATING INDEX"
|
77
|
+
spine_col ([str]):
|
78
|
+
if agg index, key columns - can be none
|
79
|
+
if join index, join column
|
80
|
+
other_col ([str]):
|
81
|
+
if agg index, aggregating columns
|
82
|
+
if join index, dimension column
|
83
|
+
#}
|
84
|
+
{{ create_statement }} "{{ index_name }}" ON {{ relation }} (
|
85
|
+
{% if spine_col -%}
|
86
|
+
{% if spine_col is iterable and spine_col is not string -%}
|
87
|
+
{{ spine_col | join(', ') }},
|
88
|
+
{% else -%}
|
89
|
+
{{ spine_col }},
|
90
|
+
{% endif -%}
|
91
|
+
{%- endif -%}
|
92
|
+
{% if other_col is iterable and other_col is not string -%}
|
93
|
+
{{ other_col | join(', ') }}
|
94
|
+
{%- else -%}
|
95
|
+
{{ other_col }}
|
96
|
+
{%- endif -%}
|
97
|
+
);
|
98
|
+
{% endmacro %}
|
99
|
+
|
100
|
+
|
101
|
+
{% macro drop_index(index_name, index_type) -%}
|
102
|
+
{# Drop aggregating or join index. #}
|
103
|
+
{% call statement('drop_index', auto_begin=False) %}
|
104
|
+
|
105
|
+
DROP {{ index_type | upper }} INDEX "{{ index_name }}"
|
106
|
+
{% endcall %}
|
107
|
+
{% endmacro %}
|
108
|
+
|
109
|
+
|
110
|
+
{% macro firebolt__get_create_index_sql(relation, index_dict) -%}
|
111
|
+
{# Return aggregating or join index SQL string. #}
|
112
|
+
{# Parse index inputs and send parsed input to make_create_index_sql #}
|
113
|
+
{%- set index_config = adapter.parse_index(index_dict) -%}
|
114
|
+
{%- set index_name = index_config.render_name(relation) -%}
|
115
|
+
{%- set index_type = index_config.index_type | upper -%}
|
116
|
+
{%- if index_type == "JOIN" -%}
|
117
|
+
{{ make_create_index_sql(relation,
|
118
|
+
index_name,
|
119
|
+
"CREATE JOIN INDEX",
|
120
|
+
index_config.join_columns,
|
121
|
+
index_config.dimension_column) }}
|
122
|
+
{%- elif index_type == "AGGREGATING" -%}
|
123
|
+
{{ make_create_index_sql(relation,
|
124
|
+
index_name,
|
125
|
+
"CREATE AND GENERATE AGGREGATING INDEX",
|
126
|
+
index_config.key_columns,
|
127
|
+
index_config.aggregation) }}
|
128
|
+
{%- endif -%}
|
129
|
+
{%- endmacro %}
|
130
|
+
|
131
|
+
|
132
|
+
{% macro sql_convert_columns_in_relation_firebolt(rows) -%}
|
133
|
+
{% set columns = [] %}
|
134
|
+
{% for row in rows %}
|
135
|
+
{% do columns.append(api.Column(*row)) %}
|
136
|
+
{% endfor %}
|
137
|
+
{{ return(columns) }}
|
138
|
+
{% endmacro %}
|
139
|
+
|
140
|
+
|
141
|
+
{% macro firebolt__get_columns_in_relation(relation) -%}
|
142
|
+
{#-
|
143
|
+
Return column information for table identified by relation as
|
144
|
+
List[FireboltColumn].
|
145
|
+
Args: relation: dbt Relation
|
146
|
+
-#}
|
147
|
+
{% set sql %}
|
148
|
+
SELECT column_name, data_type from information_schema.columns
|
149
|
+
WHERE table_name = '{{ relation.identifier }}'
|
150
|
+
{% endset %}
|
151
|
+
{%- set result = run_query(sql) -%}
|
152
|
+
{% set columns = [] %}
|
153
|
+
{% for row in result %}
|
154
|
+
{% do columns.append(adapter.get_column_class().from_description(row['column_name'],
|
155
|
+
adapter.resolve_special_columns(row['data_type']))) %}
|
156
|
+
{% endfor %}
|
157
|
+
{% do return(columns) %}
|
158
|
+
{% endmacro %}
|
159
|
+
|
160
|
+
|
161
|
+
{% macro firebolt__list_relations_without_caching(relation) %}
|
162
|
+
{# Return all views and tables as agate table.
|
163
|
+
Args:
|
164
|
+
relation (dict): Contains values for database and schema.
|
165
|
+
|
166
|
+
dbt has a relations cache. Using this macro will list all
|
167
|
+
the relations in the current schema using a direct DB query,
|
168
|
+
rather than checking the cache. So the name is a misnomer. Should
|
169
|
+
be list_relations_bypassing_cache or something.
|
170
|
+
#}
|
171
|
+
{% call statement('list_tables_without_caching', fetch_result=True) %}
|
172
|
+
|
173
|
+
SELECT
|
174
|
+
table_catalog AS "database",
|
175
|
+
table_name AS "name",
|
176
|
+
'{{ relation.schema }}' AS "schema",
|
177
|
+
CASE
|
178
|
+
WHEN table_type = 'VIEW' THEN 'view'
|
179
|
+
ELSE 'table'
|
180
|
+
END AS "type"
|
181
|
+
FROM
|
182
|
+
information_schema.tables
|
183
|
+
{% endcall %}
|
184
|
+
{% set info_table = load_result('list_tables_without_caching').table %}
|
185
|
+
{{ return(info_table) }}
|
186
|
+
{% endmacro %}
|
187
|
+
|
188
|
+
{% macro firebolt__truncate_relation(relation) -%}
|
189
|
+
{#
|
190
|
+
Truncate relation. Actual macro is drop_relation in ./adapters/relation.sql.
|
191
|
+
#}
|
192
|
+
|
193
|
+
{# Firebolt doesn't currently support TRUNCATE, so DROP CASCADE.
|
194
|
+
This should only be called from reset_csv_table, where it's followed by
|
195
|
+
`create_csv_table`, so not recreating the table here. To retrieve old code,
|
196
|
+
see commit f9984f6d61b8a1b877bc107b102eeb30eba54f35
|
197
|
+
This will be replaced by `CREATE OR REPLACE`. #}
|
198
|
+
{{ adapter.drop_relation(relation) }}
|
199
|
+
{% endmacro %}
|
@@ -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,16 @@
|
|
1
|
+
dbt/adapters/firebolt/__init__.py,sha256=kvZHfzL2BcAonSjs_WCktruesBDSfdflPKQAzob7r3g,411
|
2
|
+
dbt/adapters/firebolt/__version__.py,sha256=zRlZGglif76ZVuWWSjsH_MMPgtVQqmj-SryYJW25FL4,69
|
3
|
+
dbt/adapters/firebolt/column.py,sha256=COo_wjhCFgS3GFcPIPcoq7WAWgzN6DB2XqG-gk51WBc,539
|
4
|
+
dbt/adapters/firebolt/connections.py,sha256=dNdha5dDEYUPhLvlSq8_ftbBA1hiqnUCBukt6wLuZH4,7976
|
5
|
+
dbt/adapters/firebolt/impl.py,sha256=eIqnXzoMoyHq2lp1yMz7O62WJ0apM16H8IssTTwDMiw,15075
|
6
|
+
dbt/adapters/firebolt/relation.py,sha256=Xg3Nrjw3UrF_qwnuGbPT97rSXRiDP1GlIAoBF4b7QnY,1922
|
7
|
+
dbt/adapters/firebolt/relation_configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
dbt/include/firebolt/__init__.py,sha256=vBGWeG-dHHkimfnX8axBJ4IgAowFw8xADmo6Auzn2xc,52
|
9
|
+
dbt/include/firebolt/dbt_project.yml,sha256=uHJ-i0wD1D74DWSSSzsFKoKbAN1w4LBgVpnkm8e-M1g,76
|
10
|
+
dbt/include/firebolt/macros/adapters.sql,sha256=SMWEr_gK7iZP72Zdl2Tx0zB5fS0VQhJXhGB_4wJVlHc,6918
|
11
|
+
dbt/include/firebolt/macros/catalog.sql,sha256=LLhjI9oEoMEQKQfE3LJ5nWS9-u3bwBAYBz4ukrsg5T8,3350
|
12
|
+
dbt_firebolt-1.9.3.dist-info/LICENSE,sha256=Nn0EGvW3qmoZpBV_JVM3iPukFf3RiNCIizrWe_2oTHk,11354
|
13
|
+
dbt_firebolt-1.9.3.dist-info/METADATA,sha256=90c23zvFpa_9o0QSa881L0rd1A1tRKlq02S7lxcuMoA,5237
|
14
|
+
dbt_firebolt-1.9.3.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
15
|
+
dbt_firebolt-1.9.3.dist-info/top_level.txt,sha256=B2YH4he17ajilEWOGCKHbRcEJlCuZKwCcgFcLPntLsE,4
|
16
|
+
dbt_firebolt-1.9.3.dist-info/RECORD,,
|
@@ -1,13 +0,0 @@
|
|
1
|
-
dbt/adapters/firebolt/__init__.py,sha256=BqeuV6kaWEP3BG901X9rr9ifw8y-qBwHuB2ulefwbHo,411
|
2
|
-
dbt/adapters/firebolt/__version__.py,sha256=zRlZGglif76ZVuWWSjsH_MMPgtVQqmj-SryYJW25FL4,69
|
3
|
-
dbt/adapters/firebolt/column.py,sha256=COo_wjhCFgS3GFcPIPcoq7WAWgzN6DB2XqG-gk51WBc,539
|
4
|
-
dbt/adapters/firebolt/connections.py,sha256=dNdha5dDEYUPhLvlSq8_ftbBA1hiqnUCBukt6wLuZH4,7976
|
5
|
-
dbt/adapters/firebolt/impl.py,sha256=eIqnXzoMoyHq2lp1yMz7O62WJ0apM16H8IssTTwDMiw,15075
|
6
|
-
dbt/adapters/firebolt/relation.py,sha256=Xg3Nrjw3UrF_qwnuGbPT97rSXRiDP1GlIAoBF4b7QnY,1922
|
7
|
-
dbt/adapters/firebolt/relation_configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
dbt/include/firebolt/__init__.py,sha256=vBGWeG-dHHkimfnX8axBJ4IgAowFw8xADmo6Auzn2xc,52
|
9
|
-
dbt_firebolt-1.9.2.dist-info/LICENSE,sha256=Nn0EGvW3qmoZpBV_JVM3iPukFf3RiNCIizrWe_2oTHk,11354
|
10
|
-
dbt_firebolt-1.9.2.dist-info/METADATA,sha256=wuRMDg_FlCCBHiC90xZqEJ0OWE27FVJYeUvC83YACss,5237
|
11
|
-
dbt_firebolt-1.9.2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
12
|
-
dbt_firebolt-1.9.2.dist-info/top_level.txt,sha256=B2YH4he17ajilEWOGCKHbRcEJlCuZKwCcgFcLPntLsE,4
|
13
|
-
dbt_firebolt-1.9.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|