Skip to content

Commit

Permalink
Supports new error messages. (#520) (#530)
Browse files Browse the repository at this point in the history
* Supports new error messages.

* changie

* tuple

* fix.

* suggestion.

Co-authored-by: Takuya UESHIN <ueshin@databricks.com>
  • Loading branch information
McKnight-42 and ueshin authored Dec 2, 2022
1 parent 17b84a9 commit ad48026
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20221116-234601.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Support new error messages in the future Spark.
time: 2022-11-16T23:46:01.899921861Z
custom:
Author: ueshin
Issue: "515"
PR: "520"
9 changes: 8 additions & 1 deletion dbt/adapters/spark/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
KEY_TABLE_OWNER = "Owner"
KEY_TABLE_STATISTICS = "Statistics"

TABLE_OR_VIEW_NOT_FOUND_MESSAGES = (
"[TABLE_OR_VIEW_NOT_FOUND]",
"Table or view not found",
"NoSuchTableException",
)


@dataclass
class SparkConfig(AdapterConfig):
Expand Down Expand Up @@ -220,7 +226,8 @@ def get_columns_in_relation(self, relation: Relation) -> List[SparkColumn]:
# spark would throw error when table doesn't exist, where other
# CDW would just return and empty list, normalizing the behavior here
errmsg = getattr(e, "msg", "")
if "Table or view not found" in errmsg or "NoSuchTableException" in errmsg:
found_msgs = (msg in errmsg for msg in TABLE_OR_VIEW_NOT_FOUND_MESSAGES)
if any(found_msgs):
pass
else:
raise e
Expand Down

0 comments on commit ad48026

Please sign in to comment.