def _parse_exception(self, e): error_type = QueryExecutionErrorType.INTERNAL.value error_str = str(e) error_extracted = None if isinstance(e, TrinoQueryError): try: line_number, column_number = e.error_location return get_parsed_syntax_error( e.message, line_number - 1, column_number - 1, ) except Exception: return QueryExecutionErrorType.ENGINE.value, e.message, error_extracted if isinstance(e, Error): error_type = QueryExecutionErrorType.ENGINE.value try: error_dict = get_trino_error_dict(e) if error_dict: error_extracted = error_dict.get("message", None) except Exception: pass return error_type, error_str, error_extracted
def _parse_exception(self, e): error_type = QueryExecutionErrorType.INTERNAL.value error_str = str(e) error_extracted = None try: if isinstance(e, Error): error_type = QueryExecutionErrorType.ENGINE.value error_dict = get_presto_error_dict(e) if error_dict: error_extracted = error_dict.get("message", None) # In Presto, only context free syntax error are labelled as # SYNTAX_ERROR, and context sensitive errors are user errors # However in both cases errorLocation is provided if "errorLocation" in error_dict: return get_parsed_syntax_error( error_extracted, error_dict["errorLocation"].get("lineNumber", 1) - 1, error_dict["errorLocation"].get("columnNumber", 1) - 1, ) except Exception: pass return error_type, error_str, error_extracted
def _parse_exception(self, e): if isinstance(e, SQLAlchemyError): orig_error = getattr(e, "orig", None) if isinstance(orig_error, sf_errors.ProgrammingError): message = orig_error.msg match = re.search(r"error line (\d+) at position (\d+)", message) if match is not None: return get_parsed_syntax_error(message, int(match.group(1)) - 1, int(match.group(2))) return super(SnowflakeQueryExecutor, self)._parse_exception(e)
def _parse_exception(self, e): error_type = QueryExecutionErrorType.INTERNAL.value error_str = str(e) error_extracted = None if isinstance(e, SQLAlchemyError): error_type = QueryExecutionErrorType.ENGINE.value if isinstance(e, DBAPIError) and len(e.orig.args) == 2: code, message = e.orig.args if code == 1064: match = re.search(r"at line (\d+)", message) return get_parsed_syntax_error( str(e.orig.args), int(match.group(1)) - 1 if match is not None else None, ) return error_type, error_str, error_extracted
def _parse_exception(self, e): error_type = QueryExecutionErrorType.INTERNAL.value error_str = str(e) error_extracted = None try: if isinstance(e, Error): error_type = QueryExecutionErrorType.ENGINE.value error_obj = get_hive_error_obj(e) if error_obj: if error_obj.__class__.__name__ == "TExecuteStatementResp": error_extracted = error_obj.status.errorMessage error_code = error_obj.status.errorCode sql_state = error_obj.status.sqlState # According to # https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java # Error code between 10000 to 19999 are compiler erros is_compiler_error = (10000 <= error_code <= 19999) or ( error_code == 40000 and sql_state == "42000") if is_compiler_error: match = re.search(r"(?i)Line (\d+):(\d+)", error_extracted) if match: return get_parsed_syntax_error( error_extracted, int(match.group(1)) - 1, # hive's char position is 0 based, strange int(match.group(2)), ) elif error_obj.__class__.__name__ == "TFetchResultsResp": error_extracted = error_obj.status.errorMessage elif error_str.startswith( "Error while processing statement: FAILED: Execution Error, return code " ): error_type = QueryExecutionErrorType.ENGINE.value query_diagnostics = [] for job_id, job_url in self._mr_jobs: query_diagnostics += diagnose_query(job_url, job_id) if len(query_diagnostics): error_str = ( "Query failed. " + "Found the following error from Logs (Check Mapreduce url for details):\n" + "\n----\n".join(query_diagnostics)) except Exception: pass return error_type, error_str, error_extracted