Skip to content
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

fix: Presto postgres test #15163

Merged
merged 1 commit into from Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/celery_tests.py
Expand Up @@ -147,6 +147,25 @@ def test_run_sync_query_dont_exist(setup_sqllab, ctas_method):
result = run_sql(sql_dont_exist, cta=True, ctas_method=ctas_method)
if backend() == "sqlite" and ctas_method == CtasMethod.VIEW:
assert QueryStatus.SUCCESS == result["status"], result
elif backend() == "presto":
assert (
result["errors"][0]["error_type"]
== SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR
)
assert result["errors"][0]["level"] == ErrorLevel.ERROR
assert result["errors"][0]["extra"] == {
"engine_name": "Presto",
"issue_codes": [
{
"code": 1003,
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.",
},
{
"code": 1005,
"message": "Issue 1005 - The table was deleted or renamed in the database.",
},
],
}
else:
assert (
result["errors"][0]["error_type"]
Expand Down
48 changes: 35 additions & 13 deletions tests/sqllab_tests.py
Expand Up @@ -42,6 +42,7 @@
)
from superset.sql_parse import CtasMethod
from superset.utils.core import (
backend,
datetime_to_epoch,
get_example_database,
get_main_database,
Expand Down Expand Up @@ -84,19 +85,40 @@ def test_sql_json(self):
self.assertLess(0, len(data["data"]))

data = self.run_sql("SELECT * FROM unexistant_table", "2")
assert (
data["errors"][0]["error_type"] == SupersetErrorType.GENERIC_DB_ENGINE_ERROR
)
assert data["errors"][0]["level"] == ErrorLevel.ERROR
assert data["errors"][0]["extra"] == {
"issue_codes": [
{
"code": 1002,
"message": "Issue 1002 - The database returned an unexpected error.",
}
],
"engine_name": engine_name,
}
if backend() == "presto":
assert (
data["errors"][0]["error_type"]
== SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR
)
assert data["errors"][0]["level"] == ErrorLevel.ERROR
assert data["errors"][0]["extra"] == {
"engine_name": "Presto",
"issue_codes": [
{
"code": 1003,
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.",
},
{
"code": 1005,
"message": "Issue 1005 - The table was deleted or renamed in the database.",
},
],
}
else:
assert (
data["errors"][0]["error_type"]
== SupersetErrorType.GENERIC_DB_ENGINE_ERROR
)
assert data["errors"][0]["level"] == ErrorLevel.ERROR
assert data["errors"][0]["extra"] == {
"issue_codes": [
{
"code": 1002,
"message": "Issue 1002 - The database returned an unexpected error.",
}
],
"engine_name": engine_name,
}

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_sql_json_to_saved_query_info(self):
Expand Down