From 0cc99c50a7db91447ee0a84b4cfba80539298dc9 Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Wed, 12 Jun 2019 15:39:12 -0600 Subject: [PATCH 1/2] for snapshots, make the argument "--select", not "--models" --- core/dbt/main.py | 11 +++++++---- .../004_simple_snapshot_test/test_simple_snapshot.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/dbt/main.py b/core/dbt/main.py index 107ff234b8e..20df0380b36 100644 --- a/core/dbt/main.py +++ b/core/dbt/main.py @@ -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=""" @@ -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) diff --git a/test/integration/004_simple_snapshot_test/test_simple_snapshot.py b/test/integration/004_simple_snapshot_test/test_simple_snapshot.py index 3dd3b902bee..f4da4aaedb2 100644 --- a/test/integration/004_simple_snapshot_test/test_simple_snapshot.py +++ b/test/integration/004_simple_snapshot_test/test_simple_snapshot.py @@ -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') From 4a10c8dce797804ca92ecf7c94e9470d6a05440e Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Fri, 7 Jun 2019 08:38:27 -0600 Subject: [PATCH 2/2] fix bigquery test --- .../004_simple_snapshot_test/test_simple_snapshot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/004_simple_snapshot_test/test_simple_snapshot.py b/test/integration/004_simple_snapshot_test/test_simple_snapshot.py index f4da4aaedb2..a3385627648 100644 --- a/test/integration/004_simple_snapshot_test/test_simple_snapshot.py +++ b/test/integration/004_simple_snapshot_test/test_simple_snapshot.py @@ -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.