-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Tworkiewicz
committed
Feb 4, 2022
1 parent
2263ec5
commit 4782b6f
Showing
4 changed files
with
151 additions
and
15 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,56 @@ | ||
## teradata_utils 0.0.2 | ||
|
||
### Features | ||
* Added tests and/or implementations for the following `dbt_utils` macros: | ||
* pivot | ||
* unpivot | ||
* get_url_parameter | ||
* Added support for multi-character delimiters in `split_part` macro. | ||
|
||
### Fixes | ||
|
||
### Docs | ||
|
||
### Under the hood | ||
|
||
|
||
## teradata_utils 0.0.1 | ||
|
||
### Features | ||
* initial release that covers the following `dbt_utils` macros: | ||
* equal_rowcount | ||
* fewer_rows_than | ||
* equality | ||
* expression_is_true | ||
* recency | ||
* at_least_one | ||
* not_constant | ||
* cardinality_equality | ||
* not_null_proportion | ||
* not_accepted_values | ||
* relationships_where | ||
* mutually_exclusive_ranges | ||
* sequential_values | ||
* unique_combination_of_columns | ||
* accepted_range | ||
* get_column_values | ||
* get_relations_by_pattern | ||
* get_relations_by_prefix | ||
* get_query_results_as_dict | ||
* date_spine | ||
* haversine_distance | ||
* group_by | ||
* star | ||
* union_relations | ||
* generate_series | ||
* surrogate_key | ||
* safe_add | ||
|
||
|
||
### Fixes | ||
|
||
### Docs | ||
* Initial documentation | ||
|
||
### Under the hood | ||
* Added tests |
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,12 +1,18 @@ | ||
{# The default implementation does not quote function parameters #} | ||
{# Also, the function used in the original macro ('split_part') is called 'strtok' in Teradata #} | ||
{# The function used in the original macro ('split_part') is called 'strtok' in Teradata #} | ||
|
||
{% macro default__split_part(string_text, delimiter_text, part_number) %} | ||
|
||
{% if delimiter_text|length == 1 %} | ||
strtok( | ||
'{{ string_text }}', | ||
'{{ delimiter_text }}', | ||
{{ string_text }}, | ||
{{ delimiter_text }}, | ||
{{ part_number }} | ||
) | ||
|
||
{% else %} | ||
-- This is a hack. We are replacing the delimiter text with chr(1). We then let strtok() tokenize. | ||
-- chr(1) Is a unique character. If there is chr(1) in the search string this query will produce hard-to-debug errors. | ||
strtok(oreplace({{ string_text }}, {{ delimiter_text }}, chr(1)), | ||
chr(1), | ||
{{ part_number }} | ||
) | ||
{% endif %} | ||
{% endmacro %} |
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,69 @@ | ||
target: | ||
type: teradata | ||
server: "{{ env_var('DBT_TERADATA_SERVER_NAME', 'localhost') }}" | ||
username: "{{ env_var('DBT_TERADATA_USERNAME', 'dbc') }}" | ||
password: "{{ env_var('DBT_TERADATA_PASSWORD', 'dbc') }}" | ||
schema: "dbt_test_{{ var('_dbt_random_suffix') }}" | ||
tmode: ANSI | ||
log: "0" | ||
|
||
projects: | ||
- name: project_for_test | ||
paths: | ||
dbt_project.yml: | | ||
name: 'project_for_test' | ||
version: '1.0.0' | ||
config-version: 2 | ||
dispatch: | ||
- macro_namespace: dbt_utils | ||
search_order: | ||
- teradata_utils | ||
- dbt_utils | ||
seeds: | ||
project_for_test: # you must include the project name | ||
test_table1: | ||
+column_types: | ||
date: date | ||
size: varchar(1) | ||
color: varchar(5) | ||
status: varchar(15) | ||
|
||
packages.yml: | | ||
packages: | ||
- package: dbt-labs/dbt_utils | ||
version: 0.8.0 | ||
- local: "{{ env_var('DBT_TERADATA_UTILS_ROOT') }}" | ||
|
||
seeds/urls.csv: | | ||
id,url | ||
1,https://github.com/dbt-labs/dbt-utils#pivot-source?utm_source=123 | ||
2,https://search.google.com/u/1/search-console/mobile-usability?resource_id=https://quickstarts.teradata.com/&utm_source=123&utm_medium=gamma&utm_campaign=wnc_10030322&utm_content=msg_100058679&hl=en | ||
|
||
models/report.sql: | | ||
{{ | ||
config( | ||
materialized="table" | ||
) | ||
}} | ||
SELECT {{ dbt_utils.get_url_parameter(field='url', url_parameter='utm_source') }} AS utm_source_value | ||
FROM {{ ref('urls') }} | ||
WHERE utm_source_value = '123' | ||
|
||
|
||
sequences: | ||
test: | ||
project: project_for_test | ||
sequence: | ||
- type: dbt | ||
cmd: deps | ||
- type: dbt | ||
cmd: seed | ||
- type: dbt | ||
cmd: run | ||
- type: run_results | ||
exists: True | ||
names: | ||
- report | ||
- type: relation_rows | ||
name: report | ||
length: 2 |
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