dbt-adapters 1.22.2__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/__about__.py +1 -0
- dbt/adapters/__init__.py +8 -0
- dbt/adapters/base/README.md +13 -0
- dbt/adapters/base/__init__.py +16 -0
- dbt/adapters/base/column.py +173 -0
- dbt/adapters/base/connections.py +429 -0
- dbt/adapters/base/impl.py +2036 -0
- dbt/adapters/base/meta.py +150 -0
- dbt/adapters/base/plugin.py +32 -0
- dbt/adapters/base/query_headers.py +106 -0
- dbt/adapters/base/relation.py +648 -0
- dbt/adapters/cache.py +521 -0
- dbt/adapters/capability.py +63 -0
- dbt/adapters/catalogs/__init__.py +14 -0
- dbt/adapters/catalogs/_client.py +54 -0
- dbt/adapters/catalogs/_constants.py +1 -0
- dbt/adapters/catalogs/_exceptions.py +39 -0
- dbt/adapters/catalogs/_integration.py +113 -0
- dbt/adapters/clients/__init__.py +0 -0
- dbt/adapters/clients/jinja.py +24 -0
- dbt/adapters/contracts/__init__.py +0 -0
- dbt/adapters/contracts/connection.py +229 -0
- dbt/adapters/contracts/macros.py +11 -0
- dbt/adapters/contracts/relation.py +160 -0
- dbt/adapters/events/README.md +51 -0
- dbt/adapters/events/__init__.py +0 -0
- dbt/adapters/events/adapter_types_pb2.py +2 -0
- dbt/adapters/events/base_types.py +36 -0
- dbt/adapters/events/logging.py +83 -0
- dbt/adapters/events/types.py +436 -0
- dbt/adapters/exceptions/__init__.py +40 -0
- dbt/adapters/exceptions/alias.py +24 -0
- dbt/adapters/exceptions/cache.py +68 -0
- dbt/adapters/exceptions/compilation.py +269 -0
- dbt/adapters/exceptions/connection.py +16 -0
- dbt/adapters/exceptions/database.py +51 -0
- dbt/adapters/factory.py +264 -0
- dbt/adapters/protocol.py +150 -0
- dbt/adapters/py.typed +0 -0
- dbt/adapters/record/__init__.py +2 -0
- dbt/adapters/record/base.py +291 -0
- dbt/adapters/record/cursor/cursor.py +69 -0
- dbt/adapters/record/cursor/description.py +37 -0
- dbt/adapters/record/cursor/execute.py +39 -0
- dbt/adapters/record/cursor/fetchall.py +69 -0
- dbt/adapters/record/cursor/fetchmany.py +23 -0
- dbt/adapters/record/cursor/fetchone.py +23 -0
- dbt/adapters/record/cursor/rowcount.py +23 -0
- dbt/adapters/record/handle.py +55 -0
- dbt/adapters/record/serialization.py +115 -0
- dbt/adapters/reference_keys.py +39 -0
- dbt/adapters/relation_configs/README.md +25 -0
- dbt/adapters/relation_configs/__init__.py +12 -0
- dbt/adapters/relation_configs/config_base.py +46 -0
- dbt/adapters/relation_configs/config_change.py +26 -0
- dbt/adapters/relation_configs/config_validation.py +57 -0
- dbt/adapters/sql/__init__.py +2 -0
- dbt/adapters/sql/connections.py +263 -0
- dbt/adapters/sql/impl.py +286 -0
- dbt/adapters/utils.py +69 -0
- dbt/include/__init__.py +3 -0
- dbt/include/global_project/__init__.py +4 -0
- dbt/include/global_project/dbt_project.yml +7 -0
- dbt/include/global_project/docs/overview.md +43 -0
- dbt/include/global_project/macros/adapters/apply_grants.sql +167 -0
- dbt/include/global_project/macros/adapters/columns.sql +144 -0
- dbt/include/global_project/macros/adapters/freshness.sql +32 -0
- dbt/include/global_project/macros/adapters/indexes.sql +41 -0
- dbt/include/global_project/macros/adapters/metadata.sql +105 -0
- dbt/include/global_project/macros/adapters/persist_docs.sql +33 -0
- dbt/include/global_project/macros/adapters/relation.sql +84 -0
- dbt/include/global_project/macros/adapters/schema.sql +20 -0
- dbt/include/global_project/macros/adapters/show.sql +26 -0
- dbt/include/global_project/macros/adapters/timestamps.sql +52 -0
- dbt/include/global_project/macros/adapters/validate_sql.sql +10 -0
- dbt/include/global_project/macros/etc/datetime.sql +62 -0
- dbt/include/global_project/macros/etc/statement.sql +52 -0
- dbt/include/global_project/macros/generic_test_sql/accepted_values.sql +27 -0
- dbt/include/global_project/macros/generic_test_sql/not_null.sql +9 -0
- dbt/include/global_project/macros/generic_test_sql/relationships.sql +23 -0
- dbt/include/global_project/macros/generic_test_sql/unique.sql +12 -0
- dbt/include/global_project/macros/get_custom_name/get_custom_alias.sql +36 -0
- dbt/include/global_project/macros/get_custom_name/get_custom_database.sql +32 -0
- dbt/include/global_project/macros/get_custom_name/get_custom_schema.sql +60 -0
- dbt/include/global_project/macros/materializations/configs.sql +21 -0
- dbt/include/global_project/macros/materializations/functions/aggregate.sql +65 -0
- dbt/include/global_project/macros/materializations/functions/function.sql +20 -0
- dbt/include/global_project/macros/materializations/functions/helpers.sql +20 -0
- dbt/include/global_project/macros/materializations/functions/scalar.sql +69 -0
- dbt/include/global_project/macros/materializations/hooks.sql +35 -0
- dbt/include/global_project/macros/materializations/models/clone/can_clone_table.sql +7 -0
- dbt/include/global_project/macros/materializations/models/clone/clone.sql +67 -0
- dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql +7 -0
- dbt/include/global_project/macros/materializations/models/incremental/column_helpers.sql +80 -0
- dbt/include/global_project/macros/materializations/models/incremental/incremental.sql +99 -0
- dbt/include/global_project/macros/materializations/models/incremental/is_incremental.sql +13 -0
- dbt/include/global_project/macros/materializations/models/incremental/merge.sql +120 -0
- dbt/include/global_project/macros/materializations/models/incremental/on_schema_change.sql +159 -0
- dbt/include/global_project/macros/materializations/models/incremental/strategies.sql +92 -0
- dbt/include/global_project/macros/materializations/models/materialized_view.sql +121 -0
- dbt/include/global_project/macros/materializations/models/table.sql +64 -0
- dbt/include/global_project/macros/materializations/models/view.sql +72 -0
- dbt/include/global_project/macros/materializations/seeds/helpers.sql +128 -0
- dbt/include/global_project/macros/materializations/seeds/seed.sql +60 -0
- dbt/include/global_project/macros/materializations/snapshots/helpers.sql +345 -0
- dbt/include/global_project/macros/materializations/snapshots/snapshot.sql +109 -0
- dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql +34 -0
- dbt/include/global_project/macros/materializations/snapshots/strategies.sql +184 -0
- dbt/include/global_project/macros/materializations/tests/helpers.sql +44 -0
- dbt/include/global_project/macros/materializations/tests/test.sql +66 -0
- dbt/include/global_project/macros/materializations/tests/unit.sql +40 -0
- dbt/include/global_project/macros/materializations/tests/where_subquery.sql +15 -0
- dbt/include/global_project/macros/python_model/python.sql +114 -0
- dbt/include/global_project/macros/relations/column/columns_spec_ddl.sql +89 -0
- dbt/include/global_project/macros/relations/create.sql +23 -0
- dbt/include/global_project/macros/relations/create_backup.sql +17 -0
- dbt/include/global_project/macros/relations/create_intermediate.sql +17 -0
- dbt/include/global_project/macros/relations/drop.sql +41 -0
- dbt/include/global_project/macros/relations/drop_backup.sql +14 -0
- dbt/include/global_project/macros/relations/materialized_view/alter.sql +55 -0
- dbt/include/global_project/macros/relations/materialized_view/create.sql +10 -0
- dbt/include/global_project/macros/relations/materialized_view/drop.sql +14 -0
- dbt/include/global_project/macros/relations/materialized_view/refresh.sql +9 -0
- dbt/include/global_project/macros/relations/materialized_view/rename.sql +10 -0
- dbt/include/global_project/macros/relations/materialized_view/replace.sql +10 -0
- dbt/include/global_project/macros/relations/rename.sql +35 -0
- dbt/include/global_project/macros/relations/rename_intermediate.sql +14 -0
- dbt/include/global_project/macros/relations/replace.sql +50 -0
- dbt/include/global_project/macros/relations/schema.sql +8 -0
- dbt/include/global_project/macros/relations/table/create.sql +60 -0
- dbt/include/global_project/macros/relations/table/drop.sql +14 -0
- dbt/include/global_project/macros/relations/table/rename.sql +10 -0
- dbt/include/global_project/macros/relations/table/replace.sql +10 -0
- dbt/include/global_project/macros/relations/view/create.sql +27 -0
- dbt/include/global_project/macros/relations/view/drop.sql +14 -0
- dbt/include/global_project/macros/relations/view/rename.sql +10 -0
- dbt/include/global_project/macros/relations/view/replace.sql +66 -0
- dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql +107 -0
- dbt/include/global_project/macros/utils/any_value.sql +9 -0
- dbt/include/global_project/macros/utils/array_append.sql +8 -0
- dbt/include/global_project/macros/utils/array_concat.sql +7 -0
- dbt/include/global_project/macros/utils/array_construct.sql +12 -0
- dbt/include/global_project/macros/utils/bool_or.sql +9 -0
- dbt/include/global_project/macros/utils/cast.sql +7 -0
- dbt/include/global_project/macros/utils/cast_bool_to_text.sql +7 -0
- dbt/include/global_project/macros/utils/concat.sql +7 -0
- dbt/include/global_project/macros/utils/data_types.sql +129 -0
- dbt/include/global_project/macros/utils/date.sql +10 -0
- dbt/include/global_project/macros/utils/date_spine.sql +75 -0
- dbt/include/global_project/macros/utils/date_trunc.sql +7 -0
- dbt/include/global_project/macros/utils/dateadd.sql +14 -0
- dbt/include/global_project/macros/utils/datediff.sql +14 -0
- dbt/include/global_project/macros/utils/equals.sql +14 -0
- dbt/include/global_project/macros/utils/escape_single_quotes.sql +8 -0
- dbt/include/global_project/macros/utils/except.sql +9 -0
- dbt/include/global_project/macros/utils/generate_series.sql +53 -0
- dbt/include/global_project/macros/utils/hash.sql +7 -0
- dbt/include/global_project/macros/utils/intersect.sql +9 -0
- dbt/include/global_project/macros/utils/last_day.sql +15 -0
- dbt/include/global_project/macros/utils/length.sql +11 -0
- dbt/include/global_project/macros/utils/listagg.sql +30 -0
- dbt/include/global_project/macros/utils/literal.sql +7 -0
- dbt/include/global_project/macros/utils/position.sql +11 -0
- dbt/include/global_project/macros/utils/replace.sql +14 -0
- dbt/include/global_project/macros/utils/right.sql +12 -0
- dbt/include/global_project/macros/utils/safe_cast.sql +9 -0
- dbt/include/global_project/macros/utils/split_part.sql +26 -0
- dbt/include/global_project/tests/generic/builtin.sql +30 -0
- dbt/include/py.typed +0 -0
- dbt_adapters-1.22.2.dist-info/METADATA +124 -0
- dbt_adapters-1.22.2.dist-info/RECORD +173 -0
- dbt_adapters-1.22.2.dist-info/WHEEL +4 -0
- dbt_adapters-1.22.2.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{% macro get_intervals_between(start_date, end_date, datepart) -%}
|
|
2
|
+
{{ return(adapter.dispatch('get_intervals_between', 'dbt')(start_date, end_date, datepart)) }}
|
|
3
|
+
{%- endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__get_intervals_between(start_date, end_date, datepart) -%}
|
|
6
|
+
{%- call statement('get_intervals_between', fetch_result=True) %}
|
|
7
|
+
|
|
8
|
+
select {{ dbt.datediff(start_date, end_date, datepart) }}
|
|
9
|
+
|
|
10
|
+
{%- endcall -%}
|
|
11
|
+
|
|
12
|
+
{%- set value_list = load_result('get_intervals_between') -%}
|
|
13
|
+
|
|
14
|
+
{%- if value_list and value_list['data'] -%}
|
|
15
|
+
{%- set values = value_list['data'] | map(attribute=0) | list %}
|
|
16
|
+
{{ return(values[0]) }}
|
|
17
|
+
{%- else -%}
|
|
18
|
+
{{ return(1) }}
|
|
19
|
+
{%- endif -%}
|
|
20
|
+
|
|
21
|
+
{%- endmacro %}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
{% macro date_spine(datepart, start_date, end_date) %}
|
|
27
|
+
{{ return(adapter.dispatch('date_spine', 'dbt')(datepart, start_date, end_date)) }}
|
|
28
|
+
{%- endmacro %}
|
|
29
|
+
|
|
30
|
+
{% macro default__date_spine(datepart, start_date, end_date) %}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
{# call as follows:
|
|
34
|
+
|
|
35
|
+
date_spine(
|
|
36
|
+
"day",
|
|
37
|
+
"to_date('01/01/2016', 'mm/dd/yyyy')",
|
|
38
|
+
"dbt.dateadd(week, 1, current_date)"
|
|
39
|
+
) #}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
with rawdata as (
|
|
43
|
+
|
|
44
|
+
{{dbt.generate_series(
|
|
45
|
+
dbt.get_intervals_between(start_date, end_date, datepart)
|
|
46
|
+
)}}
|
|
47
|
+
|
|
48
|
+
),
|
|
49
|
+
|
|
50
|
+
all_periods as (
|
|
51
|
+
|
|
52
|
+
select (
|
|
53
|
+
{{
|
|
54
|
+
dbt.dateadd(
|
|
55
|
+
datepart,
|
|
56
|
+
"row_number() over (order by 1) - 1",
|
|
57
|
+
start_date
|
|
58
|
+
)
|
|
59
|
+
}}
|
|
60
|
+
) as date_{{datepart}}
|
|
61
|
+
from rawdata
|
|
62
|
+
|
|
63
|
+
),
|
|
64
|
+
|
|
65
|
+
filtered as (
|
|
66
|
+
|
|
67
|
+
select *
|
|
68
|
+
from all_periods
|
|
69
|
+
where date_{{datepart}} <= {{ end_date }}
|
|
70
|
+
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
select * from filtered
|
|
74
|
+
|
|
75
|
+
{% endmacro %}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{% macro dateadd(datepart, interval, from_date_or_timestamp) %}
|
|
2
|
+
{{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}
|
|
7
|
+
|
|
8
|
+
dateadd(
|
|
9
|
+
{{ datepart }},
|
|
10
|
+
{{ interval }},
|
|
11
|
+
{{ from_date_or_timestamp }}
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
{% endmacro %}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{% macro datediff(first_date, second_date, datepart) %}
|
|
2
|
+
{{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
{% macro default__datediff(first_date, second_date, datepart) -%}
|
|
7
|
+
|
|
8
|
+
datediff(
|
|
9
|
+
{{ datepart }},
|
|
10
|
+
{{ first_date }},
|
|
11
|
+
{{ second_date }}
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{% macro equals(expr1, expr2) %}
|
|
2
|
+
{{ return(adapter.dispatch('equals', 'dbt') (expr1, expr2)) }}
|
|
3
|
+
{%- endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__equals(expr1, expr2) -%}
|
|
6
|
+
{%- if adapter.behavior.enable_truthy_nulls_equals_macro.no_warn %}
|
|
7
|
+
case when (({{ expr1 }} = {{ expr2 }}) or ({{ expr1 }} is null and {{ expr2 }} is null))
|
|
8
|
+
then 0
|
|
9
|
+
else 1
|
|
10
|
+
end = 0
|
|
11
|
+
{%- else -%}
|
|
12
|
+
({{ expr1 }} = {{ expr2 }})
|
|
13
|
+
{%- endif %}
|
|
14
|
+
{% endmacro %}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{% macro escape_single_quotes(expression) %}
|
|
2
|
+
{{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{# /*Default to replacing a single apostrophe with two apostrophes: they're -> they''re*/ #}
|
|
6
|
+
{% macro default__escape_single_quotes(expression) -%}
|
|
7
|
+
{{ expression | replace("'","''") }}
|
|
8
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{% macro get_powers_of_two(upper_bound) %}
|
|
2
|
+
{{ return(adapter.dispatch('get_powers_of_two', 'dbt')(upper_bound)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__get_powers_of_two(upper_bound) %}
|
|
6
|
+
|
|
7
|
+
{% if upper_bound <= 0 %}
|
|
8
|
+
{{ exceptions.raise_compiler_error("upper bound must be positive") }}
|
|
9
|
+
{% endif %}
|
|
10
|
+
|
|
11
|
+
{% for _ in range(1, 100) %}
|
|
12
|
+
{% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}
|
|
13
|
+
{% endfor %}
|
|
14
|
+
|
|
15
|
+
{% endmacro %}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
{% macro generate_series(upper_bound) %}
|
|
19
|
+
{{ return(adapter.dispatch('generate_series', 'dbt')(upper_bound)) }}
|
|
20
|
+
{% endmacro %}
|
|
21
|
+
|
|
22
|
+
{% macro default__generate_series(upper_bound) %}
|
|
23
|
+
|
|
24
|
+
{% set n = dbt.get_powers_of_two(upper_bound) %}
|
|
25
|
+
|
|
26
|
+
with p as (
|
|
27
|
+
select 0 as generated_number union all select 1
|
|
28
|
+
), unioned as (
|
|
29
|
+
|
|
30
|
+
select
|
|
31
|
+
|
|
32
|
+
{% for i in range(n) %}
|
|
33
|
+
p{{i}}.generated_number * power(2, {{i}})
|
|
34
|
+
{% if not loop.last %} + {% endif %}
|
|
35
|
+
{% endfor %}
|
|
36
|
+
+ 1
|
|
37
|
+
as generated_number
|
|
38
|
+
|
|
39
|
+
from
|
|
40
|
+
|
|
41
|
+
{% for i in range(n) %}
|
|
42
|
+
p as p{{i}}
|
|
43
|
+
{% if not loop.last %} cross join {% endif %}
|
|
44
|
+
{% endfor %}
|
|
45
|
+
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
select *
|
|
49
|
+
from unioned
|
|
50
|
+
where generated_number <= {{upper_bound}}
|
|
51
|
+
order by generated_number
|
|
52
|
+
|
|
53
|
+
{% endmacro %}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{% macro last_day(date, datepart) %}
|
|
2
|
+
{{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{%- macro default_last_day(date, datepart) -%}
|
|
6
|
+
cast(
|
|
7
|
+
{{dbt.dateadd('day', '-1',
|
|
8
|
+
dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))
|
|
9
|
+
)}}
|
|
10
|
+
as date)
|
|
11
|
+
{%- endmacro -%}
|
|
12
|
+
|
|
13
|
+
{% macro default__last_day(date, datepart) -%}
|
|
14
|
+
{{dbt.default_last_day(date, datepart)}}
|
|
15
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{% macro listagg(measure, delimiter_text="','", order_by_clause=none, limit_num=none) -%}
|
|
2
|
+
{{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}
|
|
3
|
+
{%- endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}
|
|
6
|
+
|
|
7
|
+
{% if limit_num -%}
|
|
8
|
+
array_to_string(
|
|
9
|
+
array_slice(
|
|
10
|
+
array_agg(
|
|
11
|
+
{{ measure }}
|
|
12
|
+
){% if order_by_clause -%}
|
|
13
|
+
within group ({{ order_by_clause }})
|
|
14
|
+
{%- endif %}
|
|
15
|
+
,0
|
|
16
|
+
,{{ limit_num }}
|
|
17
|
+
),
|
|
18
|
+
{{ delimiter_text }}
|
|
19
|
+
)
|
|
20
|
+
{%- else %}
|
|
21
|
+
listagg(
|
|
22
|
+
{{ measure }},
|
|
23
|
+
{{ delimiter_text }}
|
|
24
|
+
)
|
|
25
|
+
{% if order_by_clause -%}
|
|
26
|
+
within group ({{ order_by_clause }})
|
|
27
|
+
{%- endif %}
|
|
28
|
+
{%- endif %}
|
|
29
|
+
|
|
30
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{% macro position(substring_text, string_text) -%}
|
|
2
|
+
{{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__position(substring_text, string_text) %}
|
|
6
|
+
|
|
7
|
+
position(
|
|
8
|
+
{{ substring_text }} in {{ string_text }}
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
{%- endmacro -%}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{% macro replace(field, old_chars, new_chars) -%}
|
|
2
|
+
{{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__replace(field, old_chars, new_chars) %}
|
|
6
|
+
|
|
7
|
+
replace(
|
|
8
|
+
{{ field }},
|
|
9
|
+
{{ old_chars }},
|
|
10
|
+
{{ new_chars }}
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
{% endmacro %}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{% macro right(string_text, length_expression) -%}
|
|
2
|
+
{{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__right(string_text, length_expression) %}
|
|
6
|
+
|
|
7
|
+
right(
|
|
8
|
+
{{ string_text }},
|
|
9
|
+
{{ length_expression }}
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
{%- endmacro -%}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{% macro safe_cast(field, type) %}
|
|
2
|
+
{{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__safe_cast(field, type) %}
|
|
6
|
+
{# most databases don't support this function yet
|
|
7
|
+
so we just need to use cast #}
|
|
8
|
+
cast({{field}} as {{type}})
|
|
9
|
+
{% endmacro %}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{% macro split_part(string_text, delimiter_text, part_number) %}
|
|
2
|
+
{{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}
|
|
3
|
+
{% endmacro %}
|
|
4
|
+
|
|
5
|
+
{% macro default__split_part(string_text, delimiter_text, part_number) %}
|
|
6
|
+
|
|
7
|
+
split_part(
|
|
8
|
+
{{ string_text }},
|
|
9
|
+
{{ delimiter_text }},
|
|
10
|
+
{{ part_number }}
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
{% endmacro %}
|
|
14
|
+
|
|
15
|
+
{% macro _split_part_negative(string_text, delimiter_text, part_number) %}
|
|
16
|
+
|
|
17
|
+
split_part(
|
|
18
|
+
{{ string_text }},
|
|
19
|
+
{{ delimiter_text }},
|
|
20
|
+
length({{ string_text }})
|
|
21
|
+
- length(
|
|
22
|
+
replace({{ string_text }}, {{ delimiter_text }}, '')
|
|
23
|
+
) + 2 + {{ part_number }}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
{% endmacro %}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* {#
|
|
2
|
+
Generic tests can be defined in `macros/` or in `tests/generic`.
|
|
3
|
+
These four tests are built into the dbt-core global project.
|
|
4
|
+
To support extensibility to other adapters and SQL dialects,
|
|
5
|
+
they call 'dispatched' macros. By default, they will use
|
|
6
|
+
the SQL defined in `global_project/macros/generic_test_sql`
|
|
7
|
+
#} */
|
|
8
|
+
|
|
9
|
+
{% test unique(model, column_name) %}
|
|
10
|
+
{% set macro = adapter.dispatch('test_unique', 'dbt') %}
|
|
11
|
+
{{ macro(model, column_name) }}
|
|
12
|
+
{% endtest %}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
{% test not_null(model, column_name) %}
|
|
16
|
+
{% set macro = adapter.dispatch('test_not_null', 'dbt') %}
|
|
17
|
+
{{ macro(model, column_name) }}
|
|
18
|
+
{% endtest %}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
{% test accepted_values(model, column_name, values, quote=True) %}
|
|
22
|
+
{% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}
|
|
23
|
+
{{ macro(model, column_name, values, quote) }}
|
|
24
|
+
{% endtest %}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
{% test relationships(model, column_name, to, field) %}
|
|
28
|
+
{% set macro = adapter.dispatch('test_relationships', 'dbt') %}
|
|
29
|
+
{{ macro(model, column_name, to, field) }}
|
|
30
|
+
{% endtest %}
|
dbt/include/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dbt-adapters
|
|
3
|
+
Version: 1.22.2
|
|
4
|
+
Summary: The set of adapter protocols and base functionality that supports integration with dbt-core
|
|
5
|
+
Project-URL: Homepage, https://github.com/dbt-labs/dbt-adapters/tree/main/dbt-adapters
|
|
6
|
+
Project-URL: Documentation, https://docs.getdbt.com
|
|
7
|
+
Project-URL: Repository, https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-adapters
|
|
8
|
+
Project-URL: Issues, https://github.com/dbt-labs/dbt-adapters/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/dbt-labs/dbt-adapters/blob/main/dbt-adapters/CHANGELOG.md
|
|
10
|
+
Author-email: dbt Labs <info@dbtlabs.com>
|
|
11
|
+
Maintainer-email: dbt Labs <info@dbtlabs.com>
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: adapter,adapters,database,dbt,dbt Cloud,dbt Core,dbt Labs,dbt-core,elt
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Requires-Python: >=3.10.0
|
|
24
|
+
Requires-Dist: agate<2.0,>=1.0
|
|
25
|
+
Requires-Dist: dbt-common<2.0,>=1.36
|
|
26
|
+
Requires-Dist: dbt-protos<2.0,>=1.0.291
|
|
27
|
+
Requires-Dist: mashumaro[msgpack]<3.15,>=3.9
|
|
28
|
+
Requires-Dist: protobuf<7.0,>=6.0
|
|
29
|
+
Requires-Dist: pytz>=2015.7
|
|
30
|
+
Requires-Dist: typing-extensions<5.0,>=4.0
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<img
|
|
35
|
+
src="https://raw.githubusercontent.com/dbt-labs/dbt/ec7dee39f793aa4f7dd3dae37282cc87664813e4/etc/dbt-logo-full.svg"
|
|
36
|
+
alt="dbt logo"
|
|
37
|
+
width="500"
|
|
38
|
+
/>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://pypi.org/project/dbt-adapters/">
|
|
43
|
+
<img src="https://badge.fury.io/py/dbt-adapters.svg" />
|
|
44
|
+
</a>
|
|
45
|
+
<a target="_blank" href="https://pypi.org/project/dbt-adapters/" style="background:none">
|
|
46
|
+
<img src="https://img.shields.io/pypi/pyversions/dbt-adapters">
|
|
47
|
+
</a>
|
|
48
|
+
<a href="https://github.com/psf/black">
|
|
49
|
+
<img src="https://img.shields.io/badge/code%20style-black-000000.svg" />
|
|
50
|
+
</a>
|
|
51
|
+
<a href="https://github.com/python/mypy">
|
|
52
|
+
<img src="https://www.mypy-lang.org/static/mypy_badge.svg" />
|
|
53
|
+
</a>
|
|
54
|
+
<a href="https://pepy.tech/project/dbt-athena">
|
|
55
|
+
<img src="https://static.pepy.tech/badge/dbt-adapters/month" />
|
|
56
|
+
</a>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
# Adapters
|
|
60
|
+
|
|
61
|
+
There are two major adapter types: [base](/dbt-adapters/src/dbt/adapters/base/impl.py) and [sql](/dbt-adapters/src/dbt/adapters/sql/impl.py).
|
|
62
|
+
|
|
63
|
+
## `base`
|
|
64
|
+
|
|
65
|
+
`BaseAdapter` defines the base functionality an adapter is required to implement in order to function with `dbt-core`.
|
|
66
|
+
There are several methods which have default implementations as well as methods that require the concrete adapter to implement them.
|
|
67
|
+
|
|
68
|
+
## `sql`
|
|
69
|
+
|
|
70
|
+
`SQLAdapter` inherits from `BaseAdapter`, updates default implementations to work with SQL-based platforms,
|
|
71
|
+
and defines additional required methods to support those defaults.
|
|
72
|
+
|
|
73
|
+
# Components
|
|
74
|
+
|
|
75
|
+
An adapter is composed of several components.
|
|
76
|
+
|
|
77
|
+
- connections
|
|
78
|
+
- dialect
|
|
79
|
+
- relation caching
|
|
80
|
+
- integration with `dbt-core`
|
|
81
|
+
|
|
82
|
+
The first two are platform-specific and require significant implementation in a concrete adapter.
|
|
83
|
+
The last two are largely implemented in `dbt-adapters` with minor adjustments in a concrete adapter.
|
|
84
|
+
|
|
85
|
+
## Connections
|
|
86
|
+
|
|
87
|
+
This component is responsible for creating and managing connections to storage and compute.
|
|
88
|
+
|
|
89
|
+
#### Files
|
|
90
|
+
- `dbt/adapters/{base|sql}/connections.py`
|
|
91
|
+
|
|
92
|
+
## Dialect
|
|
93
|
+
|
|
94
|
+
This component is responsible for translating a request from `dbt-core` into a specific set of actions on the platform.
|
|
95
|
+
|
|
96
|
+
#### Files
|
|
97
|
+
- `dbt/adapters/base/column.py`
|
|
98
|
+
- `dbt/adapters/base/query_headers.py`
|
|
99
|
+
- `dbt/adapters/base/relation.py`
|
|
100
|
+
- `dbt/adapters/relation_configs/*`
|
|
101
|
+
- `dbt/adapters/clients/jinja.py`
|
|
102
|
+
- `dbt/include/global_project/*`
|
|
103
|
+
|
|
104
|
+
## Relation caching
|
|
105
|
+
|
|
106
|
+
This component is responsible for managing a local cache of relations, relation metadata, and dependencies between relations.
|
|
107
|
+
|
|
108
|
+
#### Files
|
|
109
|
+
- `dbt/adapters/cache.py`
|
|
110
|
+
|
|
111
|
+
## Integration with `dbt-core`
|
|
112
|
+
|
|
113
|
+
This component is responsible for managing the interface between `dbt-core` and a concrete adapter.
|
|
114
|
+
|
|
115
|
+
#### Files
|
|
116
|
+
- `dbt/adapters/{base|sql}/impl.py`
|
|
117
|
+
- `dbt/adapters/base/meta.py`
|
|
118
|
+
- `dbt/adapters/base/plugin.py`
|
|
119
|
+
- `dbt/adapters/capability.py`
|
|
120
|
+
- `dbt/adapters/factory.py`
|
|
121
|
+
- `dbt/adapters/protocol.py`
|
|
122
|
+
- `dbt/adapters/contracts/*`
|
|
123
|
+
- `dbt/adapters/events/*`
|
|
124
|
+
- `dbt/adapters/exceptions/*`
|