-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
26 changed files
with
522 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kind: Added | ||
body: dbt 1.7 support with tests and refactoring | ||
time: 2024-08-22T11:17:00.770973+01:00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,103 @@ | ||
{# This is for building docs. Right now it's an incomplete description of | ||
the columns (for instance, `is_nullable` is missing) but more could be added later. #} | ||
|
||
{% macro firebolt__get_catalog(information_schemas, schemas) -%} | ||
{%- call statement('catalog', fetch_result=True) %} | ||
{% macro firebolt__get_catalog(information_schema, schemas) -%} | ||
|
||
{% set query %} | ||
with tables as ( | ||
{{ firebolt__get_catalog_tables_sql(information_schema) }} | ||
{{ firebolt__get_catalog_schemas_where_clause_sql(schemas) }} | ||
), | ||
columns as ( | ||
{{ firebolt__get_catalog_columns_sql(information_schema) }} | ||
{{ firebolt__get_catalog_schemas_where_clause_sql(schemas) }} | ||
) | ||
{{ firebolt__get_catalog_results_sql() }} | ||
{%- endset -%} | ||
|
||
{{ return(run_query(query)) }} | ||
|
||
{%- endmacro %} | ||
|
||
{% macro firebolt__get_catalog_relations(information_schema, relations) -%} | ||
|
||
{% set query %} | ||
with tables as ( | ||
{{ firebolt__get_catalog_tables_sql(information_schema) }} | ||
{{ firebolt__get_catalog_relations_where_clause_sql(relations) }} | ||
), | ||
columns as ( | ||
{{ firebolt__get_catalog_columns_sql(information_schema) }} | ||
{{ firebolt__get_catalog_relations_where_clause_sql(relations) }} | ||
) | ||
{{ firebolt__get_catalog_results_sql() }} | ||
{%- endset -%} | ||
|
||
{{ return(run_query(query)) }} | ||
|
||
{%- endmacro %} | ||
|
||
|
||
{% macro firebolt__get_catalog_tables_sql(information_schema) -%} | ||
SELECT | ||
tbls.table_catalog AS table_database, | ||
tbls.table_schema as table_schema, | ||
table_type, | ||
tbls.table_name as table_name, | ||
cols.column_name as column_name, | ||
cols.data_type AS column_type, | ||
CASE | ||
WHEN table_type = 'VIEW' THEN 'VIEW' | ||
ELSE 'TABLE' | ||
END AS relation_type, | ||
cols.ordinal_position as column_index | ||
END AS relation_type | ||
FROM | ||
information_schema.tables tbls | ||
JOIN information_schema.columns cols USING (table_name) | ||
{% endcall -%} | ||
{{ return(load_result('catalog').table) }} | ||
{%- endmacro %} | ||
|
||
|
||
{% macro firebolt__get_catalog_columns_sql(information_schema) -%} | ||
select | ||
table_catalog as "table_database", | ||
table_schema as "table_schema", | ||
table_name as "table_name", | ||
column_name as "column_name", | ||
ordinal_position as "column_index", | ||
data_type as "column_type" | ||
from information_schema.columns | ||
{%- endmacro %} | ||
|
||
{% macro firebolt__get_catalog_results_sql() -%} | ||
SELECT * | ||
FROM tables | ||
JOIN columns USING ("table_database", "table_schema", "table_name") | ||
ORDER BY "column_index" | ||
{%- endmacro %} | ||
|
||
|
||
{% macro firebolt__get_catalog_schemas_where_clause_sql(schemas) -%} | ||
WHERE ({%- for schema in schemas -%} | ||
UPPER("table_schema") = UPPER('{{ schema }}'){%- if not loop.last %} OR {% endif -%} | ||
{%- endfor -%}) | ||
{%- endmacro %} | ||
|
||
|
||
{% macro firebolt__get_catalog_relations_where_clause_sql(relations) -%} | ||
WHERE ( | ||
{%- for relation in relations -%} | ||
{% if relation.schema and relation.identifier %} | ||
( | ||
UPPER("table_schema") = UPPER('{{ relation.schema }}') | ||
AND UPPER("table_name") = UPPER('{{ relation.identifier }}') | ||
) | ||
{% elif relation.schema %} | ||
( | ||
UPPER("table_schema") = UPPER('{{ relation.schema }}') | ||
) | ||
{% else %} | ||
{% do exceptions.raise_compiler_error( | ||
'`get_catalog_relations` requires a list of relations, each with a schema' | ||
) %} | ||
{% endif %} | ||
|
||
{%- if not loop.last %} OR {% endif -%} | ||
{%- endfor -%} | ||
) | ||
{%- endmacro %} |
45 changes: 0 additions & 45 deletions
45
dbt/include/firebolt/macros/materializations/materialized_view.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,3 @@ | ||
{# | ||
All these macros are stubbed with compiler errors because Firebolt does not | ||
support materialized views. | ||
#} | ||
{% materialization materialized_view, adapter='firebolt' %} | ||
|
||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
|
||
{% endmaterialization %} | ||
|
||
{% macro firebolt__get_alter_materialized_view_as_sql( | ||
relation, | ||
configuration_changes, | ||
sql, | ||
existing_relation, | ||
backup_relation, | ||
intermediate_relation | ||
) %} | ||
|
||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} | ||
|
||
|
||
{% macro firebolt__get_create_materialized_view_as_sql(relation, sql) %} | ||
|
||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
|
||
{% endmacro %} | ||
|
||
|
||
{% macro firebolt__get_replace_materialized_view_as_sql(relation, sql, existing_relation, backup_relation, intermediate_relation) %} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} | ||
|
||
|
||
{% macro firebolt__get_materialized_view_configuration_changes(existing_relation, new_config) %} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} | ||
|
||
|
||
{% macro firebolt__refresh_materialized_view(relation) -%} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} | ||
|
||
|
||
{% macro firebolt__drop_materialized_view(relation) -%} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{%- endmacro %} |
11 changes: 11 additions & 0 deletions
11
dbt/include/firebolt/macros/relations/materialized_view/alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% macro firebolt__get_alter_materialized_view_as_sql( | ||
relation, | ||
configuration_changes, | ||
sql, | ||
existing_relation, | ||
backup_relation, | ||
intermediate_relation | ||
) %} | ||
|
||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/firebolt/macros/relations/materialized_view/create.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro firebolt__get_create_materialized_view_as_sql(relation, sql) %} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/firebolt/macros/relations/materialized_view/describe.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro redshift__describe_materialized_view(relation) %} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/firebolt/macros/relations/materialized_view/drop.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro firebolt__drop_materialized_view(relation) %} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/firebolt/macros/relations/materialized_view/refresh.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro firebolt__refresh_materialized_view(relation) %} | ||
{{ exceptions.raise_compiler_error("Firebolt does not support materialized views") }} | ||
{% endmacro %} |
Oops, something went wrong.