Commit be95c45
committed
[SPARK-57778][SQL] Handle Oracle JDBC objects that are not selectable as tables
### 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, e.g. 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 were unclassified, so `tableExists` threw and table
resolution surfaced a raw `FAILED_JDBC` failure.
This adds a `JdbcDialect.isNotSelectableObjectException` predicate (Oracle recognizes
`ORA-04044`/`ORA-04063`) so:
- `JdbcUtils.tableExists` returns `false` for such objects instead of throwing;
- `JDBCRDD.resolveTable` throws a dedicated, clear error (`JDBC_OBJECT_NOT_SELECTABLE`)
instead of a generic failure.
### Why are the changes needed?
A schema legitimately contains synonyms/views that are not selectable tables; probing them
should not surface a raw external-engine error or make existence checks throw.
### Does this PR introduce any user-facing change?
Yes. Querying such an object now returns `JDBC_OBJECT_NOT_SELECTABLE` instead of a raw
`FAILED_JDBC` error, and `tableExists` returns `false` for it.
### How was this patch tested?
New cases in `OracleIntegrationSuite` (docker-integration-tests): synonym to a procedure,
synonym to a broken function, and an invalid view.1 parent aa784b0 commit be95c45
7 files changed
Lines changed: 90 additions & 1 deletion
File tree
- common/utils/src/main/resources/error
- connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2
- sql
- catalyst/src/main/scala/org/apache/spark/sql/errors
- core/src/main/scala/org/apache/spark/sql
- execution/datasources/jdbc
- jdbc
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5292 | 5292 | | |
5293 | 5293 | | |
5294 | 5294 | | |
| 5295 | + | |
| 5296 | + | |
| 5297 | + | |
| 5298 | + | |
| 5299 | + | |
| 5300 | + | |
5295 | 5301 | | |
5296 | 5302 | | |
5297 | 5303 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
203 | 206 | | |
204 | 207 | | |
205 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
206 | 263 | | |
207 | 264 | | |
208 | 265 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1703 | 1703 | | |
1704 | 1704 | | |
1705 | 1705 | | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1706 | 1717 | | |
1707 | 1718 | | |
1708 | 1719 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
808 | 808 | | |
809 | 809 | | |
810 | 810 | | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
811 | 814 | | |
812 | 815 | | |
813 | 816 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
| |||
0 commit comments