-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fire proper event for inline query error #7960
Changes from 7 commits
5bcc5a5
8620b98
89f17eb
0c14dd9
b83df89
a36ebab
bfec733
5b82a59
c844191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Inline query emit proper error message | ||
time: 2023-06-28T14:41:25.699046-07:00 | ||
custom: | ||
Author: ChenyuLInx | ||
Issue: "7940" |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ types-pytz | |
types-requests | ||
types-setuptools | ||
wheel | ||
mocker |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
import pytest | ||
|
||
from dbt.cli.main import dbtRunner | ||
from dbt.exceptions import DbtRuntimeError, TargetNotFoundError | ||
from dbt.exceptions import DbtRuntimeError, Exception as DbtException | ||
from dbt.tests.util import run_dbt, run_dbt_and_capture | ||
from tests.functional.compile.fixtures import ( | ||
first_model_sql, | ||
|
@@ -155,9 +155,7 @@ def test_select_pass_empty(self, project): | |
assert "Compiled node 'second_model' is:" in log_output | ||
|
||
def test_inline_fail(self, project): | ||
with pytest.raises( | ||
TargetNotFoundError, match="depends on a node named 'third_model' which was not found" | ||
): | ||
with pytest.raises(DbtException, match="Error parsing inline query"): | ||
run_dbt(["compile", "--inline", "select * from {{ ref('third_model') }}"]) | ||
|
||
def test_multiline_jinja(self, project): | ||
|
@@ -187,12 +185,29 @@ def test_compile_inline_not_add_node(self, project): | |
manifest = parse_result.result | ||
assert len(manifest.nodes) == 4 | ||
dbt = dbtRunner(manifest=manifest) | ||
dbt = dbtRunner() | ||
dbt.invoke( | ||
["compile", "--inline", "select * from {{ ref('second_model') }}"], | ||
populate_cache=False, | ||
) | ||
assert len(manifest.nodes) == 4 | ||
|
||
def test_compile_inline_syntax_error(self, project, mocker): | ||
patched_fire_event = mocker.patch("dbt.task.compile.fire_event") | ||
dbt = dbtRunner() | ||
res = dbt.invoke(["compile", "--inline", "select * from {{ ref(1) }}"]) | ||
# Event for parsing error | ||
patched_fire_event.assert_called_once() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't really find a better way to test things here other than making sure we call fire event and re-raised a proper error. Happy to take suggestions here. |
||
assert str(res.exception) == "Error parsing inline query" | ||
|
||
def test_compile_inline_ref_node_not_exist(self, project, mocker): | ||
patched_fire_event = mocker.patch("dbt.task.compile.fire_event") | ||
dbt = dbtRunner() | ||
res = dbt.invoke(["compile", "--inline", "select * from {{ ref('i') }}"]) | ||
# Event for parsing error | ||
patched_fire_event.assert_called_once() | ||
assert str(res.exception) == "Error parsing inline query" | ||
|
||
def test_graph_summary_output(self, project): | ||
"""Ensure that the compile command generates a file named graph_summary.json | ||
in the target directory, that the file contains valid json, and that the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove this