Repository: dbt-labs/dbt-core

Issue:
Incorrect message when skipping downstream models after error (0.12.0 alpha)
## Issue

### Issue description
Given the files:
```
-- models/broken.sql

select 1 1 1 
```

```
-- models/jerco.sql

select * from {{ ref('broken') }}
```

dbt reports:

```
$ dbt run
Found 2 models, 1 tests, 0 archives, 0 analyses, 96 macros, 4 operations, 1 seed files

12:03:30 | Concurrency: 8 threads (target='dev')
12:03:30 |

12:03:30 | 1 of 2 START view model demo_schema.broken........................... [RUN]
12:03:30 | 1 of 2 ERROR creating view model demo_schema.broken.................. [ERROR in 0.19s]
12:03:40 | 2 of 2 SKIP relation demo_schema.jerco due to ephemeral model error.. [ERROR SKIP]
Database Error in model broken (models/broken.sql)
  syntax error at or near "1"
  LINE 2:     select 1 1 1
                       ^
  compiled SQL at target/compiled/my_project/broken.sql
12:03:40 |
12:03:40 | Finished running 2 view models in 0.45s.

Completed with 2 errors:

Database Error in model broken (models/broken.sql)
  syntax error at or near "1"
  LINE 2:     select 1 1 1
                       ^
  compiled SQL at target/compiled/my_project/broken.sql

Compilation Error in referenced ephemeral model demo_schema.broken

Done. PASS=0 ERROR=2 SKIP=0 TOTAL=2
```

### Results
In this case, the `broken` model is a `view`, so this should just be a regular "skip"! I'm unsure why exactly dbt is categorizing it as a compilation error for an ephemeral model, since it was actually a regular database error on top of a view.

### System information
dbt 0.12.0-a2

### Steps to reproduce
```
-- models/broken.sql

select 1 1 1 
```

```
-- models/jerco.sql

select * from {{ ref('broken') }}
```

```
$ dbt run
```


Discussion:

Resolving patch:
diff --git a/dbt/node_runners.py b/dbt/node_runners.py
--- a/dbt/node_runners.py
+++ b/dbt/node_runners.py
@@ -167,21 +167,20 @@ def run(self, compiled_node, manifest):
     def after_execute(self, result):
         raise NotImplementedException()
 
+    def _skip_caused_by_ephemeral_failure(self):
+        if self.skip_cause is None or self.skip_cause.node is None:
+            return False
+        return self.is_ephemeral_model(self.skip_cause.node)
+
     def on_skip(self):
         schema_name = self.node.schema
         node_name = self.node.name
 
         error = None
         if not self.is_ephemeral_model(self.node):
-            if self.skip_cause is None:
-                dbt.ui.printer.print_skip_line(
-                    self.node,
-                    schema_name,
-                    node_name,
-                    self.node_index,
-                    self.num_nodes
-                )
-            else:
+            # if this model was skipped due to an upstream ephemeral model
+            # failure, print a special 'error skip' message.
+            if self._skip_caused_by_ephemeral_failure():
                 dbt.ui.printer.print_skip_caused_by_error(
                     self.node,
                     schema_name,
@@ -192,9 +191,18 @@ def on_skip(self):
                 )
                 # set an error so dbt will exit with an error code
                 error = (
-                    'Compilation Error in referenced ephemeral model {}.{}'
-                    .format(self.skip_cause.node.schema,
-                            self.skip_cause.node.name)
+                    'Compilation Error in {}, caused by compilation error '
+                    'in referenced ephemeral model {}'
+                    .format(self.node.unique_id,
+                            self.skip_cause.node.unique_id)
+                )
+            else:
+                dbt.ui.printer.print_skip_line(
+                    self.node,
+                    schema_name,
+                    node_name,
+                    self.node_index,
+                    self.num_nodes
                 )
 
         node_result = RunModelResult(self.node, skip=True, error=error)


Test patch: