Repository: dbt-labs/dbt-core

Issue:
dbt trying to parse tags in analyses even when wrapped in `raw` tags
## Issue

### Steps to Reproduce
1. Put an unknown tag within `raw` tags in a sql file, in your _analysis_ directory (note that the bug doesn't occur in a model).
```
{% raw %}
{% form %}
date_part:
    type: select
    default: day
    options: [hour, day, week, month]
{% endform %}
{% endraw %}
```
2. run `dbt compile`

### Expected Result
The following should be compiled:
```
{% form %}
date_part:
    type: select
    default: day
    options: [hour, day, week, month]
{% endform %}
```


### Actual Result
Error on compilation:
```bash
Found 0 models, 0 tests, 0 archives, 1 analyses, 122 macros, 2 operations, 0 seed files

10:56:47 | Concurrency: 1 threads (target='dev')
10:56:47 |
Encountered an error:
Runtime Error
  Compilation Error in analysis form_tag (analysis/analysis/form_tag.sql)
    Encountered unknown tag 'form'.
      line 2
        {% form %}
```

### System information
OS: MacOS Mojave
Python 3.7.1
dbt 0.12.1





Discussion:

Resolving patch:
diff --git a/dbt/compilation.py b/dbt/compilation.py
--- a/dbt/compilation.py
+++ b/dbt/compilation.py
@@ -132,7 +132,7 @@ def compile_node(self, node, manifest, extra_context=None):
 
         injected_node, _ = prepend_ctes(compiled_node, manifest)
 
-        should_wrap = {NodeType.Test, NodeType.Analysis, NodeType.Operation}
+        should_wrap = {NodeType.Test, NodeType.Operation}
         if injected_node.resource_type in should_wrap:
             # data tests get wrapped in count(*)
             # TODO : move this somewhere more reasonable


Test patch:
diff --git a/test/integration/019_analysis_tests/analysis/raw_stuff.sql b/test/integration/019_analysis_tests/analysis/raw_stuff.sql
new file mode 100644
--- /dev/null
+++ b/test/integration/019_analysis_tests/analysis/raw_stuff.sql
@@ -0,0 +1,3 @@
+{% raw %}
+{% invalid jinja stuff %}
+{% endraw %}
diff --git a/test/integration/019_analysis_tests/test_analyses.py b/test/integration/019_analysis_tests/test_analyses.py
--- a/test/integration/019_analysis_tests/test_analyses.py
+++ b/test/integration/019_analysis_tests/test_analyses.py
@@ -24,13 +24,26 @@ def project_config(self):
 
     @attr(type='postgres')
     def test_analyses(self):
+        compiled_analysis_path = os.path.normpath('target/compiled/test/analysis')
+        path_1 = os.path.join(compiled_analysis_path, 'analysis.sql')
+        path_2 = os.path.join(compiled_analysis_path, 'raw_stuff.sql')
+
+        self.run_dbt(['clean'])
+        self.assertFalse(os.path.exists(compiled_analysis_path))
+        results = self.run_dbt(["compile"])
+        self.assertEqual(len(results), 3)
+
+        self.assertTrue(os.path.exists(path_1))
+        self.assertTrue(os.path.exists(path_2))
+
+        with open(path_1) as fp:
+            self.assertEqual(
+                fp.read().strip(),
+                'select * from "{}"."my_model"'.format(self.unique_schema())
+            )
+        with open(path_2) as fp:
+            self.assertEqual(
+                fp.read().strip(),
+                '{% invalid jinja stuff %}'
+            )
 
-        results = self.run_dbt(["run"])
-        self.assertEqual(len(results), 1)
-
-        compiled_analysis_path = os.path.normpath(os.path.join(
-            'target/build-analysis',
-            self.analysis_path()
-        ))
-
-        # TODO  test that analysis file is in the right place