|
5 | 5 | from dbt.contracts.results import RunStatus, RunResult |
6 | 6 | from dbt.events.base_types import EventLevel |
7 | 7 | from dbt.events.functions import fire_event |
8 | | -from dbt.events.types import CompiledNode, Note |
9 | | -from dbt.exceptions import DbtInternalError, DbtRuntimeError |
| 8 | +from dbt.events.types import CompiledNode, Note, ParseInlineNodeError |
| 9 | +from dbt.exceptions import ( |
| 10 | + CompilationError, |
| 11 | + DbtInternalError, |
| 12 | + DbtRuntimeError, |
| 13 | + Exception as DbtException, |
| 14 | +) |
| 15 | + |
10 | 16 | from dbt.graph import ResourceTypeSelector |
11 | 17 | from dbt.node_types import NodeType |
12 | 18 | from dbt.parser.manifest import write_manifest, process_node |
@@ -129,14 +135,26 @@ def defer_to_manifest(self, adapter, selected_uids: AbstractSet[str]): |
129 | 135 |
|
130 | 136 | def _runtime_initialize(self): |
131 | 137 | if getattr(self.args, "inline", None): |
132 | | - block_parser = SqlBlockParser( |
133 | | - project=self.config, manifest=self.manifest, root_project=self.config |
134 | | - ) |
135 | | - sql_node = block_parser.parse_remote(self.args.inline, "inline_query") |
136 | | - process_node(self.config, self.manifest, sql_node) |
137 | | - # keep track of the node added to the manifest |
138 | | - self._inline_node_id = sql_node.unique_id |
139 | | - |
| 138 | + try: |
| 139 | + block_parser = SqlBlockParser( |
| 140 | + project=self.config, manifest=self.manifest, root_project=self.config |
| 141 | + ) |
| 142 | + sql_node = block_parser.parse_remote(self.args.inline, "inline_query") |
| 143 | + process_node(self.config, self.manifest, sql_node) |
| 144 | + # keep track of the node added to the manifest |
| 145 | + self._inline_node_id = sql_node.unique_id |
| 146 | + except CompilationError as exc: |
| 147 | + fire_event( |
| 148 | + ParseInlineNodeError( |
| 149 | + exc=str(exc.msg), |
| 150 | + node_info={ |
| 151 | + "node_path": "sql/inline_query", |
| 152 | + "node_name": "inline_query", |
| 153 | + "unique_id": "sqloperation.test.inline_query", |
| 154 | + }, |
| 155 | + ) |
| 156 | + ) |
| 157 | + raise DbtException("Error parsing inline query") |
140 | 158 | super()._runtime_initialize() |
141 | 159 |
|
142 | 160 | def after_run(self, adapter, results): |
|
0 commit comments