Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #25 from fishtown-analytics/feature/0.17.0
Browse files Browse the repository at this point in the history
Support 0.17.0
  • Loading branch information
beckjake authored Jun 10, 2020
2 parents e6f6542 + d113095 commit 5350cd2
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .bumpversion-dbt.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.16.1
current_version = 0.17.0
parse = (?P<major>\d+)
\.(?P<minor>\d+)
\.(?P<patch>\d+)
Expand Down
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.16.1
current_version = 0.17.0
parse = (?P<major>\d+)
\.(?P<minor>\d+)
\.(?P<patch>\d+)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
dist/
dbt-integration-tests
docker/dbt/.user.yml
.DS_Store
2 changes: 1 addition & 1 deletion dbt/adapters/presto/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.16.1'
version = '0.17.0'
19 changes: 0 additions & 19 deletions dbt/adapters/presto/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,3 @@ def convert_number_type(cls, agate_table, col_idx):
@classmethod
def convert_datetime_type(cls, agate_table, col_idx):
return "TIMESTAMP"

def drop_schema(self, database, schema, model_name=None):
"""On Presto, 'cascade' isn't supported so we have to manually cascade.
Fortunately, we don't have to worry about cross-schema views because
views (on hive at least) are non-binding.
"""
relations = self.list_relations(
database=database,
schema=schema,
model_name=model_name
)
for relation in relations:
self.drop_relation(relation, model_name=model_name)
super(PrestoAdapter, self).drop_schema(
database=database,
schema=schema,
model_name=model_name
)
2 changes: 1 addition & 1 deletion dbt/include/presto/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

name: dbt_presto
version: 1.0
config-version: 2

macro-paths: ["macros"]
14 changes: 9 additions & 5 deletions dbt/include/presto/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% endmacro %}


{% macro presto__list_relations_without_caching(information_schema, schema) %}
{% macro presto__list_relations_without_caching(relation) %}
{% call statement('list_relations_without_caching', fetch_result=True) -%}
select
table_catalog as database,
Expand All @@ -48,8 +48,8 @@
when table_type = 'VIEW' then 'view'
else table_type
end as table_type
from {{ information_schema }}.tables
where {{ presto_ilike('table_schema', schema) }}
from {{ relation.information_schema() }}.tables
where {{ presto_ilike('table_schema', relation.schema) }}
{% endcall %}
{{ return(load_result('list_relations_without_caching').table) }}
{% endmacro %}
Expand Down Expand Up @@ -96,9 +96,13 @@
{%- endmacro %}


{% macro presto__drop_schema(database_name, schema_name) -%}
{# On Presto, 'cascade' isn't supported so we have to manually cascade. #}
{% macro presto__drop_schema(relation) -%}
{% for relation in adapter.list_relations(relation.database, relation.schema) %}
{% do drop_relation(relation) %}
{% endfor %}
{%- call statement('drop_schema') -%}
drop schema if exists {{database_name}}.{{schema_name}}
drop schema if exists {{ relation }}
{% endcall %}
{% endmacro %}

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dbt-core==0.16.1
dbt-core==0.17.0
presto-python-client==0.7.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def _dbt_presto_version():
package_version = _dbt_presto_version()
description = """The presto adpter plugin for dbt (data build tool)"""

dbt_version = '0.16.1'
dbt_version = '0.17.0'
# the package version should be the dbt version, with maybe some things on the
# ends of it. (0.16.1 vs 0.16.1a1, 0.16.1.1, ...)
# ends of it. (0.17.0 vs 0.17.0a1, 0.17.0.1, ...)
if not package_version.startswith(dbt_version):
raise ValueError(
f'Invalid setup.py: package_version={package_version} must start with '
Expand Down
10 changes: 6 additions & 4 deletions test/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ def mock_connection(name):


def profile_from_dict(profile, profile_name, cli_vars='{}'):
from dbt.config import Profile, ConfigRenderer
from dbt.config import Profile
from dbt.config.renderer import ProfileRenderer
from dbt.context.base import generate_base_context
from dbt.utils import parse_cli_vars
if not isinstance(cli_vars, dict):
cli_vars = parse_cli_vars(cli_vars)

renderer = ConfigRenderer(generate_base_context(cli_vars))
renderer = ProfileRenderer(generate_base_context(cli_vars))
return Profile.from_raw_profile_info(
profile,
profile_name,
Expand All @@ -51,12 +52,13 @@ def profile_from_dict(profile, profile_name, cli_vars='{}'):

def project_from_dict(project, profile, packages=None, cli_vars='{}'):
from dbt.context.target import generate_target_context
from dbt.config import Project, ConfigRenderer
from dbt.config import Project
from dbt.config.renderer import DbtProjectYamlRenderer
from dbt.utils import parse_cli_vars
if not isinstance(cli_vars, dict):
cli_vars = parse_cli_vars(cli_vars)

renderer = ConfigRenderer(generate_target_context(profile, cli_vars))
renderer = DbtProjectYamlRenderer(generate_target_context(profile, cli_vars))

project_root = project.pop('project-root', os.getcwd())

Expand Down

0 comments on commit 5350cd2

Please sign in to comment.