forked from dbt-labs/dbt-core
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Jacob Beck
committed
Jan 16, 2019
1 parent
16d7524
commit 85389af
Showing
17 changed files
with
433 additions
and
55 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
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
-e ./plugins/redshift | ||
-e ./plugins/snowflake | ||
-e ./plugins/bigquery | ||
-e ./plugins/presto |
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
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 @@ | ||
id,dupe | ||
1,a | ||
2,a | ||
3,a | ||
4,a |
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,18 @@ | ||
|
||
{% macro test_was_materialized(model, name, type) %} | ||
|
||
{#-- don't run this query in the parsing step #} | ||
{%- if model -%} | ||
{%- set table = adapter.get_relation(database=model.database, schema=model.schema, | ||
identifier=model.name) -%} | ||
{%- else -%} | ||
{%- set table = {} -%} | ||
{%- endif -%} | ||
|
||
{% if table and table.type == type %} | ||
select 0 as success | ||
{% else %} | ||
select 1 as error | ||
{% 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,4 @@ | ||
|
||
{{ config(materialized = "ephemeral") }} | ||
|
||
select * from {{ ref('view_model') }} |
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,21 @@ | ||
|
||
view_model: | ||
constraints: | ||
not_null: | ||
- id | ||
- updated_at | ||
|
||
unique: | ||
- id | ||
- dupe # fails | ||
|
||
was_materialized: | ||
- {name: view_model, type: view} | ||
|
||
table_model: | ||
constraints: | ||
not_null: | ||
- id | ||
|
||
was_materialized: | ||
- {name: table_model, type: table} |
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,4 @@ | ||
|
||
{{ config(materialized = "table") }} | ||
|
||
select * from {{ ref('ephemeral_model') }} |
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,13 @@ | ||
{{ | ||
config( | ||
materialized = "view" | ||
) | ||
}} | ||
|
||
|
||
select | ||
id, | ||
current_date as updated_at, | ||
dupe | ||
|
||
from {{ ref('data_seed') }} |
73 changes: 73 additions & 0 deletions
73
test/integration/041_presto_test/test_simple_presto_view.py
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,73 @@ | ||
from test.integration.base import DBTIntegrationTest, FakeArgs, use_profile | ||
import random | ||
import time | ||
|
||
|
||
class TestBasePrestoRun(DBTIntegrationTest): | ||
|
||
@property | ||
def schema(self): | ||
return "presto_test_41" | ||
|
||
@property | ||
def models(self): | ||
return "test/integration/041_presto_test/models" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
'data-paths': ['test/integration/041_presto_test/data'], | ||
'macro-paths': ['test/integration/041_presto_test/macros'], | ||
} | ||
|
||
@property | ||
def profile_config(self): | ||
return self.presto_profile() | ||
|
||
def assert_nondupes_pass(self): | ||
# The 'dupe' model should fail, but all others should pass | ||
test_results = self.run_dbt(['test'], expect_pass=False) | ||
|
||
for result in test_results: | ||
if 'dupe' in result.node.get('name'): | ||
self.assertFalse(result.errored) | ||
self.assertFalse(result.skipped) | ||
self.assertTrue(result.status > 0) | ||
|
||
# assert that actual tests pass | ||
else: | ||
self.assertFalse(result.errored) | ||
self.assertFalse(result.skipped) | ||
# status = # of failing rows | ||
self.assertEqual(result.status, 0) | ||
|
||
|
||
class TestSimplePrestoRun(TestBasePrestoRun): | ||
def setUp(self): | ||
super(TestSimplePrestoRun, self).setUp() | ||
for conn in self.adapter.connections.in_use.values(): | ||
conn.transaction_open | ||
|
||
@use_profile('presto') | ||
def test__presto_simple_run(self): | ||
# make sure seed works twice. Full-refresh is a no-op | ||
self.run_dbt(['seed']) | ||
self.run_dbt(['seed', '--full-refresh']) | ||
results = self.run_dbt() | ||
self.assertEqual(len(results), 2) | ||
self.assert_nondupes_pass() | ||
|
||
|
||
class TestUnderscorePrestoRun(TestBasePrestoRun): | ||
prefix = "_test{}{:04}".format(int(time.time()), random.randint(0, 9999)) | ||
|
||
@use_profile('presto') | ||
def test_presto_run_twice(self): | ||
self.run_dbt(['seed']) | ||
results = self.run_dbt() | ||
self.assertEqual(len(results), 2) | ||
self.assert_nondupes_pass() | ||
results = self.run_dbt() | ||
self.assertEqual(len(results), 2) | ||
self.assert_nondupes_pass() | ||
|
Oops, something went wrong.