ivan-leventsov opened a new pull request, #56898:
URL: https://github.com/apache/spark/pull/56898
### What changes were proposed in this pull request?
When using the built-in JDBC `TableCatalog` over Oracle, the driver's table
listing returns objects that cannot be read as tables, for example a synonym
that resolves to a PL/SQL procedure/function/package, or an invalid view.
Probing such an object (`tableExists` via `SELECT 1 FROM <obj> WHERE 1=0`, or
schema resolution via `SELECT * FROM <obj> WHERE 1=0`) raises `ORA-04044`
("procedure, function, package, or type is not allowed here") or `ORA-04063`
("... has errors"). These are currently unclassified, so `tableExists` throws
instead of returning `false`, and table resolution surfaces a raw `FAILED_JDBC`
error.
This PR adds a new `JdbcDialect.isNotSelectableObjectException` predicate
(default `false`; `OracleDialect` recognizes `ORA-04044`/`ORA-04063`), kept
separate from `isObjectNotFoundException` ("object does not exist"). With it:
- `JdbcUtils.tableExists` returns `false` for such objects instead of
throwing;
- `JDBCRDD.resolveTable` throws a dedicated, clear error condition
`JDBC_OBJECT_NOT_SELECTABLE` instead of a generic failure.
### Why are the changes needed?
A schema legitimately contains synonyms/views that are not selectable as
tables. Probing them should not surface a raw external-engine error or make
existence checks throw; such objects should be reported as not a readable table.
### Does this PR introduce _any_ user-facing change?
Yes. For a JDBC catalog over Oracle:
- reading an object that is not selectable as a table now fails with the
dedicated error condition `JDBC_OBJECT_NOT_SELECTABLE` (SQLSTATE `42000`)
instead of a raw `FAILED_JDBC` error;
- `tableExists` returns `false` for such an object instead of throwing.
### How was this patch tested?
New cases in `org.apache.spark.sql.jdbc.v2.OracleIntegrationSuite`
(docker-integration-tests), covering a synonym to a procedure, a synonym to a
broken function (both `ORA-04044`), and an invalid view (`ORA-04063`). Each
asserts that `tableExists` returns `false` and that reading the object fails
with `JDBC_OBJECT_NOT_SELECTABLE`.
### Was this patch authored or co-authored using generative AI tooling?
Yes, co-authored using Cursor (AI assistant).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]