Skip to content

Commit

Permalink
Update is_non_sqlalchemy_error to support pysparks AnalysisException
Browse files Browse the repository at this point in the history
  • Loading branch information
b1ackout committed May 27, 2024
1 parent d951b42 commit e95d599
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/sql/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
from sqlglot.errors import ParseError
from sqlalchemy.exc import SQLAlchemyError
from ploomber_core.dependencies import requires

try:
from pyspark.sql.utils import AnalysisException
except ModuleNotFoundError:
AnalysisException = None

import ast
from os.path import isfile
import re
Expand Down Expand Up @@ -556,12 +562,14 @@ def is_non_sqlalchemy_error(error):
"pyodbc.ProgrammingError",
# Clickhouse errors
"DB::Exception:",
# Pyspark
"UNRESOLVED_ROUTINE",
"PARSE_SYNTAX_ERROR",
"AnalysisException",
]
return any(msg in str(error) for msg in specific_db_errors)
is_pyspark_analysis_exception = (
isinstance(error, AnalysisException) if AnalysisException else False
)
return (
any(msg in str(error) for msg in specific_db_errors)
or is_pyspark_analysis_exception
)


def if_substring_exists(string, substrings):
Expand Down

0 comments on commit e95d599

Please sign in to comment.