-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
3099471
commit c40944c
Showing
20 changed files
with
650 additions
and
12 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
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,5 @@ | ||
{% macro tidb__bool_or(expression) -%} | ||
|
||
max({{ expression }}) | ||
|
||
{%- 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,8 @@ | ||
{% macro tidb__cast_bool_to_text(field) %} | ||
|
||
case {{ field }} | ||
when true then 'true' | ||
when false then 'false' | ||
end | ||
|
||
{% 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,30 @@ | ||
{% macro tidb__date_trunc(datepart, date) -%} | ||
|
||
{%- if datepart =='day' -%} | ||
|
||
DATE_FORMAT({{date}}, '%Y-%m-%d') | ||
|
||
{%- elif datepart == 'month' -%} | ||
|
||
DATE_FORMAT({{date}}, '%Y-%m-01') | ||
|
||
{%- elif datepart == 'quarter' -%} | ||
|
||
case QUARTER({{date}}) | ||
when 1 then DATE_FORMAT({{date}}, '%Y-01-01') | ||
when 2 then DATE_FORMAT({{date}}, '%Y-04-01') | ||
when 2 then DATE_FORMAT({{date}}, '%Y-07-01') | ||
when 2 then DATE_FORMAT({{date}}, '%Y-10-01') | ||
end | ||
|
||
{%- elif datepart == 'year' -%} | ||
|
||
DATE_FORMAT({{date}}, '%Y-01-01') | ||
|
||
{%- else -%} | ||
|
||
{{ exceptions.raise_compiler_error("macro date_trunc not implemented for datepart ~ '" ~ datepart ~ "' ~ on TiDB") }} | ||
|
||
{%- 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,8 @@ | ||
{% macro tidb__dateadd(datepart, interval, from_date_or_timestamp) %} | ||
|
||
DATE_ADD( | ||
{{ from_date_or_timestamp }}, | ||
interval {{ interval }} {{ datepart }} | ||
) | ||
|
||
{% 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,14 @@ | ||
-- the behavior is a little different from default_datediff that it will round down rather than round up | ||
-- and millisecond is not supported | ||
{% macro tidb__datediff(first_date, second_date, datepart) -%} | ||
{%- if datepart =='millisecond' -%} | ||
|
||
{{ exceptions.raise_compiler_error("macro datediff not implemented for datepart ~ '" ~ datepart ~ "' ~ on TiDB") }} | ||
|
||
{%- else -%} | ||
|
||
TIMESTAMPDIFF({{datepart}},{{first_date}},{{second_date}}) | ||
|
||
{%- 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,5 @@ | ||
{% macro tidb__hash(field) -%} | ||
|
||
md5(cast({{ field }} as CHAR)) | ||
|
||
{%- 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,15 @@ | ||
{% macro tidb__split_part(string_text, delimiter_text, part_number) %} | ||
|
||
|
||
{% if part_number >= 0 %} | ||
|
||
SUBSTRING_INDEX(SUBSTRING_INDEX({{ string_text }}, {{ delimiter_text }}, {{ part_number }}), {{ delimiter_text }}, -1) | ||
|
||
{% else %} | ||
|
||
SUBSTRING_INDEX(SUBSTRING_INDEX({{ string_text }}, {{ delimiter_text }}, {{ part_number }}), {{ delimiter_text }}, 1) | ||
|
||
{% 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 |
---|---|---|
|
@@ -5,5 +5,4 @@ filterwarnings = | |
env_files = | ||
test.env | ||
testpaths = | ||
test/integration | ||
test/functional |
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,6 +1,6 @@ | ||
dbt-core==1.1.1 | ||
dbt-core==1.2.0 | ||
mysql-connector-python>=8.0.0,<8.1 | ||
pytest~=7.0 | ||
markupsafe==2.0.1 | ||
dbt-tests-adapter==1.1.1 | ||
dbt-tests-adapter==1.2.0 | ||
pytest-dotenv |
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
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
Oops, something went wrong.