Repository: dbt-labs/dbt-core

Issue:
[Wilt Chamberlain] Snapshot updates
## Issue

### Issue description
This issue is a collection of changes and questions that came up during the testing of Snapshots for the 0.14.0 release.

**Checklist**:
- [ ] Snapshot schemas are searched in `dbt run` invocations. Is that correct / necessary?
- [ ] Snapshots do not work with source columns that _must_ be quoted. The initial snapshot will succeed (create table as) but subsequent snapshots appear to fail.
- [ ] Let's normalize the stdout for a snapshot job. This can just print the relation name, much like the output for `dbt run`.


Discussion:

Resolving patch:
diff --git a/core/dbt/node_runners.py b/core/dbt/node_runners.py
--- a/core/dbt/node_runners.py
+++ b/core/dbt/node_runners.py
@@ -486,11 +486,7 @@ def after_execute(self, result):
 
 class SnapshotRunner(ModelRunner):
     def describe_node(self):
-        cfg = self.node.get('config', {})
-        return (
-            "snapshot {name} --> {target_database}.{target_schema}.{name}"
-            .format(name=self.node.name, **cfg)
-        )
+        return "snapshot {}".format(self.node.name)
 
     def print_result_line(self, result):
         dbt.ui.printer.print_snapshot_result_line(result, self.node_index,
diff --git a/core/dbt/ui/printer.py b/core/dbt/ui/printer.py
--- a/core/dbt/ui/printer.py
+++ b/core/dbt/ui/printer.py
@@ -191,7 +191,7 @@ def print_snapshot_result_line(result, index, total):
     info, status = get_printable_result(result, 'snapshotted', 'snapshotting')
     cfg = model.get('config', {})
 
-    msg = "{info} {name} --> {target_database}.{target_schema}.{name}".format(
+    msg = "{info} {name}".format(
         info=info, name=model.name, **cfg)
     print_fancy_output_line(
         msg,


Test patch:
diff --git a/test/integration/004_simple_snapshot_test/invalidate_postgres.sql b/test/integration/004_simple_snapshot_test/invalidate_postgres.sql
--- a/test/integration/004_simple_snapshot_test/invalidate_postgres.sql
+++ b/test/integration/004_simple_snapshot_test/invalidate_postgres.sql
@@ -13,7 +13,7 @@ where id >= 10 and id <= 20;
 
 
 update {schema}.snapshot_castillo_expected set
-    dbt_valid_to   = updated_at + interval '1 hour'
+    dbt_valid_to   = "1-updated_at" + interval '1 hour'
 where id >= 10 and id <= 20;
 
 
diff --git a/test/integration/004_simple_snapshot_test/seed.sql b/test/integration/004_simple_snapshot_test/seed.sql
--- a/test/integration/004_simple_snapshot_test/seed.sql
+++ b/test/integration/004_simple_snapshot_test/seed.sql
@@ -88,7 +88,7 @@ create table {database}.{schema}.snapshot_castillo_expected (
     ip_address VARCHAR(20),
 
     -- snapshotting fields
-    updated_at TIMESTAMP WITHOUT TIME ZONE,
+    "1-updated_at" TIMESTAMP WITHOUT TIME ZONE,
     dbt_valid_from TIMESTAMP WITHOUT TIME ZONE,
     dbt_valid_to   TIMESTAMP WITHOUT TIME ZONE,
     dbt_scd_id     VARCHAR(32),
@@ -104,7 +104,7 @@ insert into {database}.{schema}.snapshot_castillo_expected (
     email,
     gender,
     ip_address,
-    updated_at,
+    "1-updated_at",
     dbt_valid_from,
     dbt_valid_to,
     dbt_updated_at,
diff --git a/test/integration/004_simple_snapshot_test/seed_pg.sql b/test/integration/004_simple_snapshot_test/seed_pg.sql
--- a/test/integration/004_simple_snapshot_test/seed_pg.sql
+++ b/test/integration/004_simple_snapshot_test/seed_pg.sql
@@ -90,7 +90,7 @@ create table {database}.{schema}.snapshot_castillo_expected (
     ip_address VARCHAR(20),
 
     -- snapshotting fields
-    updated_at TIMESTAMP WITHOUT TIME ZONE,
+    "1-updated_at" TIMESTAMP WITHOUT TIME ZONE,
     dbt_valid_from TIMESTAMP WITHOUT TIME ZONE,
     dbt_valid_to   TIMESTAMP WITHOUT TIME ZONE,
     dbt_scd_id     TEXT,
@@ -105,7 +105,7 @@ insert into {database}.{schema}.snapshot_castillo_expected (
     email,
     gender,
     ip_address,
-    updated_at,
+    "1-updated_at",
     dbt_valid_from,
     dbt_valid_to,
     dbt_updated_at,
diff --git a/test/integration/004_simple_snapshot_test/test-snapshots-select/snapshot.sql b/test/integration/004_simple_snapshot_test/test-snapshots-select/snapshot.sql
--- a/test/integration/004_simple_snapshot_test/test-snapshots-select/snapshot.sql
+++ b/test/integration/004_simple_snapshot_test/test-snapshots-select/snapshot.sql
@@ -6,10 +6,10 @@
             target_schema=schema,
             unique_key='id || ' ~ "'-'" ~ ' || first_name',
             strategy='timestamp',
-            updated_at='updated_at',
+            updated_at='"1-updated_at"',
         )
     }}
-    select * from {{target.database}}.{{schema}}.seed where last_name = 'Castillo'
+    select id,first_name,last_name,email,gender,ip_address,updated_at as "1-updated_at" from {{target.database}}.{{schema}}.seed where last_name = 'Castillo'
 
 {% endsnapshot %}
 
diff --git a/test/integration/004_simple_snapshot_test/update.sql b/test/integration/004_simple_snapshot_test/update.sql
--- a/test/integration/004_simple_snapshot_test/update.sql
+++ b/test/integration/004_simple_snapshot_test/update.sql
@@ -38,7 +38,7 @@ insert into {database}.{schema}.snapshot_castillo_expected (
     email,
     gender,
     ip_address,
-    updated_at,
+    "1-updated_at",
     dbt_valid_from,
     dbt_valid_to,
     dbt_updated_at,
@@ -177,7 +177,7 @@ insert into {database}.{schema}.snapshot_castillo_expected (
     email,
     gender,
     ip_address,
-    updated_at,
+    "1-updated_at",
     dbt_valid_from,
     dbt_valid_to,
     dbt_updated_at,
diff --git a/test/integration/base.py b/test/integration/base.py
--- a/test/integration/base.py
+++ b/test/integration/base.py
@@ -752,10 +752,7 @@ def _assertTablesEqualSql(self, relation_a, relation_b, columns=None):
         if columns is None:
             columns = self.get_relation_columns(relation_a)
 
-        if self.adapter_type == 'snowflake':
-            columns_csv = ", ".join(['"{}"'.format(record[0]) for record in columns])
-        else:
-            columns_csv = ", ".join(['{}'.format(record[0]) for record in columns])
+        columns_csv = ', '.join([self.adapter.quote(record[0]) for record in columns])
 
         if self.adapter_type == 'bigquery':
             except_operator = 'EXCEPT DISTINCT'