-
Notifications
You must be signed in to change notification settings - Fork 36
dbt 1.10 migration #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
dbt 1.10 migration #310
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4f4961b
Version and requirements update
99Lys 9282a58
Sample mode
99Lys 868a9be
Fix dbt-core required version
99Lys 44d6408
Remove unused import so tests dont fail
99Lys 46251d9
Include NO-OP in expected output
99Lys 401e2d5
Fix import collision in empty test
99Lys 9bd609c
Remove automatically handled dependency
99Lys f0cc653
Use correct binary type - varbinary
99Lys 1904515
Ensure actual failures are not repeating
99Lys 6b87e2e
Revert "Fix import collision in empty test"
99Lys e868d06
Fix issues caused by sample mode test location
99Lys 850377b
Changelog and small fix
99Lys 326a194
Add comment
99Lys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,79 @@ | ||
| import datetime | ||
| import os | ||
| from unittest import mock | ||
| import pytest | ||
|
|
||
| from dbt.tests.adapter.sample_mode.test_sample_mode import ( | ||
| BaseSampleModeTest, | ||
| ) | ||
| from dbt.tests.util import run_dbt | ||
| from tests.utils.util import BUCKET, relation_from_name | ||
| from pprint import pformat | ||
|
|
||
| # Use UTC time to match dbt-core's sample mode window calculation | ||
| now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) | ||
| twelve_hours_ago = now - datetime.timedelta(hours=12) | ||
| two_days_ago = now - datetime.timedelta(days=2) | ||
|
|
||
| _input_model_sql = f""" | ||
| {{{{ config(materialized='table', event_time='event_time') }}}} | ||
| select 1 as id, cast('{two_days_ago.strftime('%Y-%m-%d %H:%M:%S')}' as timestamp) as event_time | ||
| UNION ALL | ||
| select 2 as id, cast('{twelve_hours_ago.strftime('%Y-%m-%d %H:%M:%S')}' as timestamp) as event_time | ||
| UNION ALL | ||
| select 3 as id, cast('{now.strftime('%Y-%m-%d %H:%M:%S')}' as timestamp) as event_time | ||
| """ | ||
|
|
||
| class TestDremioSampleMode(BaseSampleModeTest): | ||
| @pytest.fixture(scope="class") | ||
| def input_model_sql(self) -> str: | ||
| """ | ||
| This is the SQL that defines the input model to be sampled, including any {{ config(..) }}. | ||
| event_time is a required configuration of this input | ||
| """ | ||
| return _input_model_sql | ||
|
|
||
| # Override this fixture to set the proper root_path | ||
| @pytest.fixture(scope="class") | ||
| def dbt_profile_data( | ||
| self, unique_schema, dbt_profile_target, profiles_config_update | ||
| ): | ||
| profile = { | ||
| "test": { | ||
| "outputs": { | ||
| "default": {}, | ||
| }, | ||
| "target": "default", | ||
| }, | ||
| } | ||
| target = dbt_profile_target | ||
| target["schema"] = unique_schema | ||
| target["root_path"] = f"{BUCKET}.{unique_schema}" | ||
| profile["test"]["outputs"]["default"] = target | ||
|
|
||
| if profiles_config_update: | ||
| profile.update(profiles_config_update) | ||
| return profile | ||
|
|
||
| # Pasting the original function here so it uses our relation_from_name | ||
| def assert_row_count(self, project, relation_name: str, expected_row_count: int): | ||
| relation = relation_from_name(project.adapter, relation_name) | ||
| result = project.run_sql(f"select * from {relation}", fetch="all") | ||
|
|
||
| assert len(result) == expected_row_count, f"{relation_name}:{pformat(result)}" | ||
|
|
||
| @mock.patch.dict(os.environ, {"DBT_EXPERIMENTAL_SAMPLE_MODE": "True"}) | ||
| def test_sample_mode(self, project) -> None: | ||
| _ = run_dbt(["run"]) | ||
| self.assert_row_count( | ||
| project=project, | ||
| relation_name="model_that_samples_input_sql", | ||
| expected_row_count=3, | ||
| ) | ||
|
|
||
| _ = run_dbt(["run", "--sample=1 day"]) | ||
| self.assert_row_count( | ||
| project=project, | ||
| relation_name="model_that_samples_input_sql", | ||
| expected_row_count=2, | ||
| ) |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.