Skip to content

Commit

Permalink
fix: Presto postgres test (apache#15163)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored and cccs-RyanS committed Dec 17, 2021
1 parent bfa3005 commit e09fec4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 13 deletions.
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

0 comments on commit e09fec4

Please sign in to comment.