-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update/create-drop-schemas
- Loading branch information
Showing
56 changed files
with
584 additions
and
2,605 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
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,3 @@ | ||
from pkgutil import extend_path | ||
|
||
__path__ = extend_path(__path__, __name__) |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[mypy] | ||
mypy_path = ./third-party-stubs | ||
mypy_path = third-party-stubs/ | ||
namespace_packages = True | ||
exclude = third-party-stubs/* |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
BIGQUERY_TEST_DATABASE= | ||
BIGQUERY_TEST_ALT_DATABASE= | ||
BIGQUERY_TEST_NO_ACCESS_DATABASE= | ||
BIGQUERY_TEST_SERVICE_ACCOUNT_JSON='{}' |
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,62 @@ | ||
from dbt.tests.util import AnyString, AnyFloat | ||
|
||
|
||
def bigquery_stats(is_table, partition=None, cluster=None): | ||
stats = {} | ||
|
||
if is_table: | ||
stats.update( | ||
{ | ||
"num_bytes": { | ||
"id": "num_bytes", | ||
"label": AnyString(), | ||
"value": AnyFloat(), | ||
"description": AnyString(), | ||
"include": True, | ||
}, | ||
"num_rows": { | ||
"id": "num_rows", | ||
"label": AnyString(), | ||
"value": AnyFloat(), | ||
"description": AnyString(), | ||
"include": True, | ||
}, | ||
} | ||
) | ||
|
||
if partition is not None: | ||
stats.update( | ||
{ | ||
"partitioning_type": { | ||
"id": "partitioning_type", | ||
"label": AnyString(), | ||
"value": partition, | ||
"description": AnyString(), | ||
"include": True, | ||
} | ||
} | ||
) | ||
|
||
if cluster is not None: | ||
stats.update( | ||
{ | ||
"clustering_fields": { | ||
"id": "clustering_fields", | ||
"label": AnyString(), | ||
"value": cluster, | ||
"description": AnyString(), | ||
"include": True, | ||
} | ||
} | ||
) | ||
|
||
has_stats = { | ||
"id": "has_stats", | ||
"label": "Has Stats?", | ||
"value": bool(stats), | ||
"description": "Indicates whether there are statistics for this table", | ||
"include": False, | ||
} | ||
stats["has_stats"] = has_stats | ||
|
||
return stats |
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,54 @@ | ||
import pytest | ||
from dbt.tests.util import run_dbt | ||
|
||
# This is to test a edge case found in https://github.com/dbt-labs/dbt-bigquery/pull/165/files | ||
|
||
tests__get_cols_in_sql = """ | ||
{% test get_cols_in(model) %} | ||
{# The step which causes the issue #} | ||
{%- set relation = api.Relation.create(identifier=model.table) if execute -%} | ||
{% set columns = adapter.get_columns_in_relation(relation) %} | ||
select | ||
{% for col in columns %} | ||
{{ col.name }} {{ "," if not loop.last }} | ||
{% endfor %} | ||
from {{ model }} | ||
limit 0 | ||
{% endtest %} | ||
""" | ||
|
||
models__my_model = """select 1 as id, 'text' as another_col | ||
""" | ||
|
||
properties__model_yml = """ | ||
version: 2 | ||
models: | ||
- name: my_model | ||
tests: | ||
- get_cols_in | ||
""" | ||
|
||
class TestIncompleteRelationSetup: | ||
@pytest.fixture(scope="class") | ||
def properties(self): | ||
return {"properties__model_yml.yml": properties__model_yml} | ||
|
||
@pytest.fixture(scope="class") | ||
def macros(self): | ||
return {"get_col_in.sql": tests__get_cols_in_sql} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { "my_model.sql": models__my_model } | ||
|
||
|
||
class TestIncompleteRelation(TestIncompleteRelationSetup): | ||
|
||
def test_incomplete_relation(self, project): | ||
run_dbt(["build"]) | ||
|
Oops, something went wrong.