sepuri sai krishna created SPARK-59852:
------------------------------------------
Summary: Classify only syntax error SQLSTATEs as syntax errors in
H2 and Derby dialects
Key: SPARK-59852
URL: https://issues.apache.org/jira/browse/SPARK-59852
Project: Spark
Issue Type: Bug
Components: SQL
Affects Versions: 5.0.0
Reporter: sepuri sai krishna
{{H2Dialect}} and {{DerbyDialect}} treat every SQLSTATE of class 42 as a syntax
error ({{startsWith("42")}}), but {{JdbcDialect.isSyntaxErrorBestEffort}}
promises that a {{true}} result is guaranteed to be a syntax error. Class 42
also covers errors such as table not found, column not found and missing
privileges, so these are reported as {{JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR}}
instead of keeping the original exception.
For example, reading a table that does not exist through {{spark.read.jdbc}}
(or the {{dbtable}} / {{query}} options) fails with
{{JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR.DURING_OUTPUT_SCHEMA_RESOLUTION}}, because
{{isObjectNotFoundException}} is only checked for catalog tables.
The SQLSTATEs the drivers actually use for syntax errors are:
* H2 ({{org.h2.api.ErrorCode}}): {{42000}} ({{SYNTAX_ERROR_1}}) and {{42001}}
({{SYNTAX_ERROR_2}}). Other class-42 states include {{42S02}} (table not
found), {{42S22}} (column not found) and {{42S01}} (table already exists).
* Derby ({{SQLState}}): {{42X01}} ({{LANG_SYNTAX_ERROR}}) and {{42X02}}
({{LANG_LEXICAL_ERROR}}). Other class-42 states include {{42X05}} (table not
found), {{42X04}} (column not found), {{42Y03}} (function not found) and
{{42502}} (missing privilege).
This is a follow-up of SPARK-59336, which made the same change for PostgreSQL.
The same pattern in these and other dialects was pointed out in its review:
https://github.com/apache/spark/pull/58621#discussion_r3968178897
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]