Skip to content

Commit

Permalink
[Backport 1.2.latest] Remove unneeded code. (#169)
Browse files Browse the repository at this point in the history
* Remove unneeded code. (#167)

* Remove unneeded code.

* Add test for this branch and fix.

Co-authored-by: Mila Page <[email protected]>
(cherry picked from commit fe91015)

* Adding changelog

Co-authored-by: Mila Page <[email protected]>
Co-authored-by: Leah Antkiewicz <[email protected]>
  • Loading branch information
3 people authored Aug 18, 2022
1 parent a6329a1 commit d053685
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20220818-122011.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Removing unneeded code for truncation logic
time: 2022-08-18T12:20:11.855469-04:00
custom:
Author: VersusFacit
Issue: "150"
PR: "167"
24 changes: 0 additions & 24 deletions dbt/include/redshift/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -230,30 +230,6 @@
{{ return(result) }}
{%- endmacro %}

-- TODO: streamline the underlying postgres macro and pass in param of 127 here
{% macro redshift__make_relation_with_suffix(base_relation, suffix, dstring) %}
{% if dstring %}
{% set dt = modules.datetime.datetime.now() %}
{% set dtstring = dt.strftime("%H%M%S%f") %}
{% set suffix = suffix ~ dtstring %}
{% endif %}
{% set suffix_length = suffix|length %}
{% set relation_max_name_length = 127 %}
{% if suffix_length > relation_max_name_length %}
{% do exceptions.raise_compiler_error('Relation suffix is too long (' ~ suffix_length ~ ' characters). Maximum length is ' ~ relation_max_name_length ~ ' characters.') %}
{% endif %}
{% set identifier = base_relation.identifier[:relation_max_name_length - suffix_length] ~ suffix %}

{{ return(base_relation.incorporate(path={"identifier": identifier })) }}

{% endmacro %}

{% macro redshift__make_temp_relation(base_relation, suffix) %}
{% set temp_relation = redshift__make_relation_with_suffix(base_relation, suffix, dstring=True) %}
{{ return(temp_relation.incorporate(path={"schema": none,
"database": none})) }}
{% endmacro %}


{% macro redshift__persist_docs(relation, model, for_relation, for_columns) -%}
{% if for_relation and config.persist_relation_docs() and model.description %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def models(self):
relname_63_chars_long = (
"relation_whose_name_is_63_chars_long_abcdefghijklmnopqrstuvwxyz.sql"
)
relname_63_chars_long_b = (
"relation_whose_name_is_63_chars_long_abcdefghijklmnopqrstuvwxya.sql"
)
relname_64_chars_long = (
"relation_whose_name_is_64_chars_long_abcdefghijklmnopqrstuvwxyz0.sql"
)
Expand All @@ -105,12 +108,16 @@ def models(self):
relname_51_chars_long: models__inc_relationname_51_chars_long,
relname_52_chars_long: models__relationname_52_chars_long,
relname_63_chars_long: models__relationname_63_chars_long,
relname_63_chars_long_b: models__relationname_63_chars_long,
relname_64_chars_long: models__relationname_64_chars_long,
relname_127_chars_long: models__relationname_127_chars_long
}

def test_long_name_succeeds(self, project):
run_dbt(["run"], expect_pass=True)
run_dbt(["run", "--threads", "2"], expect_pass=True)
# warn: second run will trigger the collision at Redshift relation
# name length max
run_dbt(["run", "--threads", "2"], expect_pass=True)


class TestAdapterDDLExceptions(TestAdapterDDLBase):
Expand Down

0 comments on commit d053685

Please sign in to comment.