dbt-firebolt 1.9.3__py3-none-any.whl → 1.9.4__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.
Files changed (52) hide show
  1. dbt/adapters/firebolt/__init__.py +1 -1
  2. dbt/include/firebolt/macros/adapters/apply_grants.sql +37 -0
  3. dbt/include/firebolt/macros/adapters/relation.sql +49 -0
  4. dbt/include/firebolt/macros/dbt_external_tables/create_external_table.sql +141 -0
  5. dbt/include/firebolt/macros/dbt_external_tables/dropif.sql +6 -0
  6. dbt/include/firebolt/macros/dbt_external_tables/get_external_build_plan.sql +18 -0
  7. dbt/include/firebolt/macros/materializations/clone.sql +3 -0
  8. dbt/include/firebolt/macros/materializations/materialized_view.sql +3 -0
  9. dbt/include/firebolt/macros/materializations/models/incremental/column_helpers.sql +21 -0
  10. dbt/include/firebolt/macros/materializations/models/incremental/incremental.sql +131 -0
  11. dbt/include/firebolt/macros/materializations/models/incremental/is_incremental.sql +14 -0
  12. dbt/include/firebolt/macros/materializations/models/incremental/merge.sql +38 -0
  13. dbt/include/firebolt/macros/materializations/models/incremental/on_schema_change.sql +90 -0
  14. dbt/include/firebolt/macros/materializations/models/incremental/strategies.sql +132 -0
  15. dbt/include/firebolt/macros/materializations/seed.sql +42 -0
  16. dbt/include/firebolt/macros/materializations/snapshot_merge.sql +19 -0
  17. dbt/include/firebolt/macros/materializations/table.sql +40 -0
  18. dbt/include/firebolt/macros/materializations/test.sql +15 -0
  19. dbt/include/firebolt/macros/materializations/view.sql +39 -0
  20. dbt/include/firebolt/macros/relations/materialized_view/alter.sql +11 -0
  21. dbt/include/firebolt/macros/relations/materialized_view/create.sql +3 -0
  22. dbt/include/firebolt/macros/relations/materialized_view/describe.sql +3 -0
  23. dbt/include/firebolt/macros/relations/materialized_view/drop.sql +3 -0
  24. dbt/include/firebolt/macros/relations/materialized_view/refresh.sql +3 -0
  25. dbt/include/firebolt/macros/relations/table/create.sql +78 -0
  26. dbt/include/firebolt/macros/relations/table/drop.sql +3 -0
  27. dbt/include/firebolt/macros/relations/table/rename.sql +6 -0
  28. dbt/include/firebolt/macros/relations/table/replace.sql +3 -0
  29. dbt/include/firebolt/macros/relations/view/create.sql +16 -0
  30. dbt/include/firebolt/macros/relations/view/drop.sql +3 -0
  31. dbt/include/firebolt/macros/relations/view/rename.sql +6 -0
  32. dbt/include/firebolt/macros/relations/view/replace.sql +3 -0
  33. dbt/include/firebolt/macros/utils/array_append.sql +3 -0
  34. dbt/include/firebolt/macros/utils/array_concat.sql +3 -0
  35. dbt/include/firebolt/macros/utils/array_construct.sql +3 -0
  36. dbt/include/firebolt/macros/utils/bool_or.sql +5 -0
  37. dbt/include/firebolt/macros/utils/cast_bool_to_text.sql +7 -0
  38. dbt/include/firebolt/macros/utils/dateadd.sql +9 -0
  39. dbt/include/firebolt/macros/utils/datediff.sql +9 -0
  40. dbt/include/firebolt/macros/utils/except.sql +6 -0
  41. dbt/include/firebolt/macros/utils/intersect.sql +6 -0
  42. dbt/include/firebolt/macros/utils/listagg.sql +27 -0
  43. dbt/include/firebolt/macros/utils/position.sql +3 -0
  44. dbt/include/firebolt/macros/utils/right.sql +12 -0
  45. dbt/include/firebolt/macros/utils/split_part.sql +14 -0
  46. dbt/include/firebolt/macros/utils/timestamps.sql +14 -0
  47. {dbt_firebolt-1.9.3.dist-info → dbt_firebolt-1.9.4.dist-info}/METADATA +1 -1
  48. dbt_firebolt-1.9.4.dist-info/RECORD +61 -0
  49. dbt_firebolt-1.9.3.dist-info/RECORD +0 -16
  50. {dbt_firebolt-1.9.3.dist-info → dbt_firebolt-1.9.4.dist-info}/LICENSE +0 -0
  51. {dbt_firebolt-1.9.3.dist-info → dbt_firebolt-1.9.4.dist-info}/WHEEL +0 -0
  52. {dbt_firebolt-1.9.3.dist-info → dbt_firebolt-1.9.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,132 @@
1
+ {% macro get_incremental_sql(strategy, source, target, unique_key, dest_columns, incremental_predicates) %}
2
+ {#
3
+ Retrieve appropriate SQL for whichever incremental strategy is given.
4
+ Args:
5
+ strategy: string, which incremental strategy is in to be used.
6
+ source: string, table from which queried results will be taken.
7
+ target: string, table into which results will be inserted.
8
+ unique_key: string, only as a placeholder for future use
9
+ dest_columns: List[string] of the names of the columns which data will be
10
+ inserted into.
11
+ #}
12
+ {%- if strategy == 'append' -%}
13
+ {#- Only insert new records into existing table, relying on user to manage
14
+ merges. -#}
15
+ {{ get_insert_only_sql(source, target, dest_columns) }}
16
+ {%- elif strategy == 'insert_overwrite' -%}
17
+ {#- Insert new data. If any data is duplicate, drop partition containing
18
+ previous data and insert new. -#}
19
+ {{ get_insert_overwrite_sql(source, target, dest_columns) }}
20
+ {%- elif strategy == 'delete+insert' -%}
21
+ {% do return(get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates)) %}
22
+ {%- elif strategy is not none -%}
23
+ {% do exceptions.raise_compiler_error('Model %s has incremental strategy %s '
24
+ 'specified, but that strategy is not '
25
+ 'supported.' % (target, strategy)) %}
26
+ {% else %}
27
+ {{ exceptions.raise_compiler_error('No incremental strategy was specified '
28
+ 'for model %s.' % (target)) }}
29
+ {%- endif -%}
30
+ {% endmacro %}
31
+
32
+
33
+ {% macro get_insert_only_sql(source, target, dest_columns) -%}
34
+ {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute="name")) %}
35
+
36
+ INSERT INTO {{ target }} ({{ dest_cols_csv }})
37
+ SELECT {{ dest_cols_csv }}
38
+ FROM {{ source }}
39
+ {%- endmacro %}
40
+
41
+
42
+ {% macro get_insert_overwrite_sql(source, target, dest_columns) %}
43
+ {#
44
+ Compile SQL to drop correct partitions in target and insert from source.
45
+ Args:
46
+ source: Relation from which queried results will be taken.
47
+ target: Relation into which results will be inserted.
48
+ dest_columns: list of the names of the columns which data will be
49
+ inserted into.
50
+ #}
51
+ {%- set partition_cols = config.get('partition_by') -%}
52
+ {%- set partition_vals = config.get('partitions') -%}
53
+ {#- Get values of partition columns for each row that will be inserted from
54
+ source. For each of those rows we'll drop the partition in the target. Use
55
+ the partition values provided in the confg block. _If_ no partition values
56
+ are provided, query the DB to find all partition values in the source table
57
+ and drop them. To match format of SQL query results, we convert each sublist
58
+ to a string. -#}
59
+ {%- if partition_vals -%}
60
+ {# Partition vals are set in config. #}
61
+ {{ drop_partitions_sql(target, partition_vals, True) }}
62
+ {%- else -%} {# No partition values were set in config. #}
63
+ {%- call statement('get_partition_cols', fetch_result=True) %}
64
+
65
+ SELECT
66
+ {% if partition_cols is iterable and partition_cols is not string -%}
67
+ DISTINCT {{ partition_cols | join(', ') }}
68
+ {%- else -%}
69
+ DISTINCT {{ partition_cols }}
70
+ {%- endif %}
71
+ FROM {{ source }}
72
+ {%- endcall -%}
73
+ {%- set partition_vals = load_result('get_partition_cols').table.rows -%}
74
+ {{ drop_partitions_sql(target, partition_vals, partition_cols, False) }}
75
+ {%- endif -%}
76
+ {%- set dest_columns = adapter.get_columns_in_relation(target) -%}
77
+ {%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}
78
+
79
+ {{ get_insert_only_sql(source, target, dest_columns) }}
80
+ {% endmacro %}
81
+
82
+
83
+ {% macro drop_partitions_sql(relation,
84
+ partition_vals,
85
+ part_col_names,
86
+ vals_set_in_config) %}
87
+ {#
88
+ Write SQL code to drop each partition in `partition_vals`.
89
+ Args:
90
+ relation: a relation whose name will be used for `DROP PARTITION` queries.
91
+ partition_vals: a list of strings, each of which begins with a '['' and
92
+ ends with a ']', as such: '[val1, val2]', and each of which represents
93
+ a partition to be dropped.
94
+ part_col_names: a list of string, the names of the partition columns.
95
+ vals_set_in_config: a boolean used to determine how to treat `partition_vals`,
96
+ whether as a list of strings or as a list of Agate rows.
97
+ #}
98
+ {%- for vals in partition_vals -%}
99
+ {%- set vals -%}
100
+ {%- if vals is iterable and vals is not string -%}
101
+ {%- if vals_set_in_config -%}
102
+ {# `vals` is a list of strings. #}
103
+ {{ vals | string() | trim() | slice(1, -1) }}
104
+ {%- else -%}
105
+ {# `vals` is a list of Agate rows. #}
106
+ {%- if 1 == (vals | length) -%}
107
+ {#- There's a weird behavior where, if dbt
108
+ queries for only a single (text?) field `join()` removes the
109
+ qoutes on the resulting string. So I have to do a little bit
110
+ of extra work. -#}
111
+ '{{ vals | join(', ') }}'
112
+ {%- else -%}
113
+ '{{ vals | join("', '") }}'
114
+ {%- endif -%}
115
+ {%- endif -%}
116
+ {%- else -%}
117
+ {{ vals }}
118
+ {%- endif -%}
119
+ {%- endset -%}
120
+ {%- set vals = vals.strip() -%}
121
+ {%- if vals.startswith("'[") -%}
122
+ {#- If a single row is returned, but has multiple values. -#}
123
+ {%- set vals = vals[2:-2] -%}
124
+ {%- endif -%}
125
+ {#- At this point, vals is a simple string of values separated by commas. -#}
126
+ {%- set col_types = adapter.get_columns_in_relation(relation) -%}
127
+ {%- set vals = adapter.annotate_date_columns_for_partitions(vals,
128
+ part_col_names,
129
+ col_types) %}
130
+ ALTER TABLE {{relation}} DROP PARTITION {{ vals.strip() }};
131
+ {%- endfor -%}
132
+ {% endmacro %}
@@ -0,0 +1,42 @@
1
+ {% macro firebolt__get_binding_char() %}
2
+ {# Override the wildcard character in prepared SQL statements. #}
3
+ {{ return('?') }}
4
+ {% endmacro %}
5
+
6
+
7
+ {% macro firebolt__create_csv_table(model, agate_table) %}
8
+ {%- set column_override = model['config'].get('column_types', {}) -%}
9
+ {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}
10
+ {% set sql %}
11
+
12
+ CREATE DIMENSION TABLE IF NOT EXISTS {{ this.render() }} (
13
+ {%- for col_name in agate_table.column_names -%}
14
+ {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}
15
+ {%- set type = column_override.get(col_name, inferred_type) -%}
16
+ {%- set column_name = (col_name | string) -%}
17
+ {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }}
18
+ {%- if not loop.last -%}, {%- endif -%}
19
+ {%- endfor -%}
20
+ )
21
+ {% endset %}
22
+ {% call statement('_') %}
23
+ {{ sql }}
24
+ {%- endcall %}
25
+ {{ return(sql) }}
26
+ {% endmacro %}
27
+
28
+
29
+ {# TODO: Make sure this is going to run correctly, or delete it. #}
30
+ {% macro firebolt__reset_csv_table(model,
31
+ full_refresh,
32
+ old_relation,
33
+ agate_table) %}
34
+ {% set sql = "" %}
35
+ {% if full_refresh %}
36
+ {{ adapter.drop_relation(old_relation) }}
37
+ {% else %}
38
+ {{ adapter.truncate_relation(old_relation) }}
39
+ {% endif %}
40
+ {% set sql = create_csv_table(model, agate_table) %}
41
+ {{ return(sql) }}
42
+ {% endmacro %}
@@ -0,0 +1,19 @@
1
+ {% macro firebolt__snapshot_merge_sql(target, source, insert_cols) -%}
2
+ {%- set insert_cols_csv = insert_cols | join(', ') -%}
3
+
4
+ UPDATE {{ target.render() }} AS DBT_INTERNAL_DEST
5
+ SET dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to
6
+ FROM {{ source }} AS DBT_INTERNAL_SOURCE
7
+ WHERE DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id
8
+ AND DBT_INTERNAL_DEST.dbt_valid_to IS NULL
9
+ AND DBT_INTERNAL_SOURCE.dbt_change_type IN ('update', 'delete');
10
+
11
+ INSERT INTO {{ target.render() }} ({{ insert_cols_csv }})
12
+ SELECT {{ insert_cols_csv }}
13
+ FROM {{ source }} AS DBT_INTERNAL_SOURCE
14
+ WHERE DBT_INTERNAL_SOURCE.dbt_scd_id NOT IN (
15
+ SELECT dbt_scd_id FROM {{ target.render() }}
16
+ )
17
+ AND DBT_INTERNAL_SOURCE.dbt_change_type = 'insert';
18
+
19
+ {% endmacro %}
@@ -0,0 +1,40 @@
1
+ {% materialization table, adapter='firebolt' %}
2
+ {# Note that a nearly identical materialization appears in table.sql. #}
3
+ {%- set identifier = model['alias'] -%} {# alias comes from where? #}
4
+
5
+ {# Temporary workaround to issue with adapter.get_relation() until
6
+ the following are resolved:
7
+ https://github.com/firebolt-db/dbt-firebolt/issues/11
8
+ https://github.com/dbt-labs/dbt-core/issues/4187
9
+ the hack is to always drop the view/table if it already exists rather than
10
+ checking the db first to see if it exists.
11
+ #}
12
+ {%- set target_relation = api.Relation.create(database=database,
13
+ schema=schema,
14
+ identifier=identifier,
15
+ type='table') -%}
16
+ {%- set target_relation_view = api.Relation.create(database=database,
17
+ schema=schema,
18
+ identifier=identifier,
19
+ type='view') -%}
20
+
21
+ {%- set grant_config = config.get('grants') -%}
22
+
23
+ {{ run_hooks(pre_hooks) }}
24
+
25
+ {% do adapter.drop_relation(target_relation) %}
26
+ {% do adapter.drop_relation(target_relation_view) %}
27
+
28
+ -- build model
29
+ {% call statement('main') -%}
30
+ {{ create_table_as(False, target_relation, sql) }}
31
+ {%- endcall %}
32
+ {% do create_indexes(target_relation) %}
33
+ {{ run_hooks(post_hooks) }}
34
+
35
+ {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}
36
+ {% do apply_grants(target_relation, grant_config, should_revoke) %}
37
+
38
+ {% do persist_docs(target_relation, model) %}
39
+ {{ return({'relations': [target_relation]}) }}
40
+ {% endmaterialization %}
@@ -0,0 +1,15 @@
1
+ {% macro firebolt__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) %}
2
+
3
+ SELECT
4
+ COALESCE(CAST({{ fail_calc }} AS INT), 0) AS failures,
5
+ CASE WHEN {{ fail_calc }} {{ warn_if }}
6
+ THEN 'true' ELSE 'false'
7
+ END AS should_warn,
8
+ CASE WHEN {{ fail_calc }} {{ error_if }}
9
+ THEN 'true' ELSE 'false'
10
+ END AS should_error
11
+ FROM (
12
+ {{ main_sql }}
13
+ {{ "LIMIT " ~ limit if limit is not none }}
14
+ ) dbt_internal_test
15
+ {%- endmacro %}
@@ -0,0 +1,39 @@
1
+ {% materialization view, adapter='firebolt' %}
2
+ {# Note that a nearly identical materialization appears
3
+ in table.sql #}
4
+ {%- set identifier = model['alias'] -%} {# alias comes from where? #}
5
+
6
+ {# Temporary workaround to issue with adapter.get_relation() until
7
+ the following are resolved:
8
+ https://github.com/firebolt-db/dbt-firebolt/issues/11
9
+ https://github.com/dbt-labs/dbt-core/issues/4187
10
+ the hack is to always drop the view/table if it already exists rather than
11
+ checking the db first to see if it exists.
12
+ #}
13
+ {%- set target_relation = api.Relation.create(database=database,
14
+ schema=schema,
15
+ identifier=identifier,
16
+ type='view') -%}
17
+ {%- set target_relation_table = api.Relation.create(database=database,
18
+ schema=schema,
19
+ identifier=identifier,
20
+ type='table') -%}
21
+ {%- set grant_config = config.get('grants') -%}
22
+
23
+ {{ run_hooks(pre_hooks) }}
24
+
25
+ {% do adapter.drop_relation(target_relation) %}
26
+ {% do adapter.drop_relation(target_relation_table) %}
27
+
28
+ -- build model
29
+ {% call statement('main') -%}
30
+ {{ create_view_as(target_relation, sql) }}
31
+ {%- endcall %}
32
+ {{ run_hooks(post_hooks) }}
33
+
34
+ {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}
35
+ {% do apply_grants(target_relation, grant_config, should_revoke) %}
36
+
37
+ {% do persist_docs(target_relation, model) %}
38
+ {{ return({'relations': [target_relation]}) }}
39
+ {% endmaterialization %}
@@ -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,78 @@
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
+ {%- if temporary -%}
28
+ {%- do adapter.drop_relation(relation) -%}
29
+ {%- endif -%}
30
+
31
+ {%- set table_type = config.get(
32
+ 'table_type',
33
+ default = 'dimension'
34
+ ) | upper -%}
35
+ {%- set primary_index = config.get('primary_index') -%}
36
+ {%- set incremental_strategy = config.get('incremental_strategy') -%}
37
+ {%- set partitions = config.get('partition_by') %}
38
+ CREATE {{ table_type }} TABLE IF NOT EXISTS {{ relation }}
39
+
40
+ {%- set contract_config = config.get('contract') -%}
41
+ {%- if contract_config.enforced -%}
42
+ {{ get_assert_columns_equivalent(select_sql) }}
43
+ {{ get_table_columns_and_constraints() }};
44
+ INSERT INTO
45
+ {{ relation }}
46
+ (
47
+ {{ adapter.dispatch(
48
+ 'get_column_names',
49
+ 'dbt'
50
+ )() }}
51
+ ) {%- set select_sql = get_select_subquery(select_sql) %}
52
+ {% endif %}
53
+
54
+ {%- if primary_index %}
55
+ primary INDEX {% if primary_index is iterable and primary_index is not string %}
56
+ "{{ primary_index | join('", "') }}"
57
+ {%- else -%}
58
+ "{{ primary_index }}"
59
+ {%- endif -%}
60
+ {%- endif -%}
61
+
62
+ {% if partitions %}
63
+ PARTITION BY {% if partitions is iterable and partitions is not string %}
64
+ {{ partitions | join(', ') }}
65
+ {%- else -%}
66
+ {{ partitions }}
67
+ {%- endif -%}
68
+ {%- endif %}
69
+
70
+ {%- if not contract_config.enforced %}
71
+ AS (
72
+ {% endif -%}
73
+
74
+ {{ select_sql }}
75
+
76
+ {% if not contract_config.enforced -%})
77
+ {%- endif -%}
78
+ {% 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 %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__array_append(array, new_element) -%}
2
+ {{ array_concat(array, [new_element]) }}
3
+ {%- endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__array_concat(array_1, array_2) -%}
2
+ array_concat({{ array_1 }}, {{ array_2 }})
3
+ {%- endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__array_construct(inputs, data_type) -%}
2
+ [{{ inputs|join(' , ') }}]
3
+ {%- endmacro %}
@@ -0,0 +1,5 @@
1
+ {% macro firebolt__bool_or(expression) -%}
2
+
3
+ MAX({{ expression }})
4
+
5
+ {%- endmacro %}
@@ -0,0 +1,7 @@
1
+ {% macro firebolt__cast_bool_to_text(field) %}
2
+ CASE
3
+ WHEN {{ field }} = false THEN 'false'
4
+ WHEN {{ field }} = true THEN 'true'
5
+ ELSE NULL
6
+ END
7
+ {% endmacro %}
@@ -0,0 +1,9 @@
1
+ {% macro firebolt__dateadd(datepart, interval, from_date_or_timestamp) %}
2
+
3
+ DATE_ADD(
4
+ '{{ datepart }}',
5
+ {{ interval }},
6
+ {{ from_date_or_timestamp }}
7
+ )
8
+
9
+ {% endmacro %}
@@ -0,0 +1,9 @@
1
+ {% macro firebolt__datediff(first_date, second_date, datepart) -%}
2
+
3
+ date_diff(
4
+ '{{ datepart }}',
5
+ {{ first_date }} :: TIMESTAMP,
6
+ {{ second_date }} :: TIMESTAMP
7
+ )
8
+
9
+ {%- endmacro %}
@@ -0,0 +1,6 @@
1
+ {% macro firebolt__except() %}
2
+
3
+ {{ exceptions.raise_compiler_error("Firebolt does not currently support "
4
+ "EXCEPT clause.") }}
5
+
6
+ {% endmacro %}
@@ -0,0 +1,6 @@
1
+ {% macro firebolt__intersect() %}
2
+
3
+ {{ exceptions.raise_compiler_error("Firebolt does not currently support "
4
+ "INTERSECT clause.") }}
5
+
6
+ {% endmacro %}
@@ -0,0 +1,27 @@
1
+ {% macro firebolt__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}
2
+
3
+ {% if order_by_clause -%}
4
+
5
+ {{ exceptions.raise_compiler_error("Firebolt does not currently support "
6
+ "ARRAY_AGG with ORDER BY clause.") }}
7
+
8
+ {%- endif %}
9
+
10
+ {% if limit_num -%}
11
+
12
+ ARRAY_JOIN(
13
+ SLICE(
14
+ ARRAY_AGG({{ measure }})
15
+ 0,
16
+ {{ limit_num }}
17
+ ),
18
+ {{ delimiter_text }}
19
+ )
20
+
21
+ {%- else %}
22
+
23
+ ARRAY_JOIN(ARRAY_AGG({{ measure }}), {{ delimiter_text }})
24
+
25
+ {%- endif %}
26
+
27
+ {%- endmacro %}
@@ -0,0 +1,3 @@
1
+ {% macro firebolt__position(substring_text, string_text) %}
2
+ STRPOS({{ string_text }}, {{ substring_text }})
3
+ {%- endmacro -%}
@@ -0,0 +1,12 @@
1
+ {% macro firebolt__right(string_text, length_expression) %}
2
+
3
+ CASE WHEN {{ length_expression }} = 0
4
+ THEN ''
5
+ ELSE
6
+ SUBSTR(
7
+ {{ string_text }},
8
+ -1 * ({{ length_expression }})
9
+ )
10
+ END
11
+
12
+ {%- endmacro -%}
@@ -0,0 +1,14 @@
1
+ {% macro firebolt__split_part(string_text, delimiter_text, part_number) %}
2
+
3
+ {% if delimiter_text.startswith("'") and delimiter_text.endswith("'") -%}
4
+ SPLIT_PART(
5
+ {{ string_text }},
6
+ {{ delimiter_text }},
7
+ {{ part_number }}
8
+ )
9
+ {%- else %}
10
+ {{ exceptions.raise_compiler_error("Firebolt does not currently support "
11
+ "reading delimiter from a column.") }}
12
+
13
+ {%- endif %}
14
+ {% endmacro %}
@@ -0,0 +1,14 @@
1
+ {% macro firebolt__current_timestamp() %}
2
+ NOW()
3
+ {% endmacro %}
4
+
5
+
6
+ {# TODO: Do we still need this?
7
+ See https://packboard.atlassian.net/browse/FIR-12156 #}
8
+ {% macro firebolt__snapshot_string_as_time(timestamp) -%}
9
+ {% call statement('timestamp', fetch_result=True) %}
10
+
11
+ SELECT CAST('{{ timestamp }}' AS DATE)
12
+ {% endcall %}
13
+ {{ return(load_result('timestamp').table) }}
14
+ {% endmacro %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt_firebolt
3
- Version: 1.9.3
3
+ Version: 1.9.4
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