Skip to content
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

for snapshots, make the argument "--select", not "--models" (#1517) #1520

Merged
merged 2 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions core/dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,13 @@ def _build_docs_generate_subparser(subparsers, base_subparser):
return generate_sub


def _add_selection_arguments(*subparsers):
def _add_selection_arguments(*subparsers, **kwargs):
models_name = kwargs.get('models_name', 'models')
for sub in subparsers:
sub.add_argument(
'-m',
'--models',
'-{}'.format(models_name[0]),
'--{}'.format(models_name),
dest='models',
required=False,
nargs='+',
help="""
Expand Down Expand Up @@ -722,7 +724,8 @@ def parse_args(args):
rpc_sub)
# --models, --exclude
_add_selection_arguments(run_sub, compile_sub, generate_sub, test_sub,
archive_sub, snapshot_sub)
archive_sub)
_add_selection_arguments(snapshot_sub, models_name='select')
# --full-refresh
_add_table_mutability_arguments(run_sub, compile_sub)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test__postgres_exclude_snapshots(self):
@use_profile('postgres')
def test__postgres_select_snapshots(self):
self.run_sql_file('seed_pg.sql')
results = self.run_dbt(['snapshot', '--models', 'snapshot_castillo'])
results = self.run_dbt(['snapshot', '--select', 'snapshot_castillo'])
self.assertEqual(len(results), 1)
self.assertTablesEqual('snapshot_castillo', 'snapshot_castillo_expected')
self.assertTableDoesNotExist('snapshot_alvarez')
Expand Down Expand Up @@ -425,7 +425,7 @@ def test__bigquery__snapshot_with_new_field(self):
# this should fail because `check="all"` will try to compare the nested field
self.run_dbt(['snapshot'], expect_pass=False)

self.run_dbt(["snapshot", '-m', 'snapshot_actual'])
self.run_dbt(["snapshot", '--select', 'snapshot_actual'])

# A more thorough test would assert that snapshotted == expected, but BigQuery does not support the
# "EXCEPT DISTINCT" operator on nested fields! Instead, just check that schemas are congruent.
Expand Down