Commit a885e27
committed
[SPARK-57750][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_3084 and set its cause
### What changes were proposed in this pull request?
Replace the legacy error condition `_LEGACY_ERROR_TEMP_3084`, raised when a Hive UDF/UDAF/UDTF wrapper class fails to instantiate during function resolution, with the descriptive condition `CANNOT_INSTANTIATE_HIVE_FUNCTION`, and attach the original failure as the exception cause.
- Add `CANNOT_INSTANTIATE_HIVE_FUNCTION` (SQLSTATE `38000`) to `error-conditions.json` and remove `_LEGACY_ERROR_TEMP_3084`.
- Add `QueryCompilationErrors.cannotInstantiateHiveFunctionError(clazz, e)` that passes `cause = Some(e)` so the inner failure is preserved on the exception chain.
- Update `HiveSessionStateBuilder.makeHiveFunctionExpression` to throw the new error and drop the manual `setStackTrace` (the attached cause now carries the inner stack trace).
- Update `HiveUDFSuite` to assert via `checkError` on the new condition, and to read the inner failure via `getCause` where the wrapped message was previously asserted.
### Why are the changes needed?
Part of the error-class migration (umbrella [SPARK-37935](https://issues.apache.org/jira/browse/SPARK-37935)). The legacy condition used a free-form `e` message parameter and did not attach the cause: the 2-arg `AnalysisException(errorClass, messageParameters)` constructor sets `cause = None`, so `getCause` returned `null` and callers/tests could not programmatically unwrap the inner failure (for example, asserting the inner condition via `checkError`).
### Does this PR introduce _any_ user-facing change?
Yes. The error condition name and message change, and the original exception is now attached as the cause. This is a change within the unreleased `master` branch only.
Before:
```
[_LEGACY_ERROR_TEMP_3084] No handler for UDF/UDAF/UDTF '<clazz>': <e>
```
After:
```
[CANNOT_INSTANTIATE_HIVE_FUNCTION] Cannot instantiate the Hive UDF/UDAF/UDTF wrapper class <clazz>. Check that the function arguments and their types are supported. SQLSTATE: 38000
```
### How was this patch tested?
By running:
- `build/sbt "core/testOnly org.apache.spark.SparkThrowableSuite"`
- `build/sbt "hive/testOnly org.apache.spark.sql.hive.execution.HiveUDFSuite"`
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor
Closes #56867 from MaxGekk/error-cond_LEGACY_ERROR_TEMP_3084.
Authored-by: Maxim Gekk <max.gekk@gmail.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
(cherry picked from commit 4810493)
Signed-off-by: Max Gekk <max.gekk@gmail.com>1 parent a19544c commit a885e27
5 files changed
Lines changed: 53 additions & 34 deletions
File tree
- common/utils/src/main/resources/error
- sql
- catalyst/src/main/scala/org/apache/spark/sql/errors
- hive/src
- main/scala/org/apache/spark/sql/hive
- test/scala/org/apache/spark/sql/hive
- execution
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
501 | 507 | | |
502 | 508 | | |
503 | 509 | | |
| |||
11325 | 11331 | | |
11326 | 11332 | | |
11327 | 11333 | | |
11328 | | - | |
11329 | | - | |
11330 | | - | |
11331 | | - | |
11332 | | - | |
11333 | 11334 | | |
11334 | 11335 | | |
11335 | 11336 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4596 | 4596 | | |
4597 | 4597 | | |
4598 | 4598 | | |
| 4599 | + | |
| 4600 | + | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
4599 | 4606 | | |
4600 | 4607 | | |
4601 | 4608 | | |
| |||
Lines changed: 2 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
246 | 245 | | |
247 | 246 | | |
248 | 247 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 248 | + | |
| 249 | + | |
256 | 250 | | |
257 | 251 | | |
258 | 252 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
Lines changed: 37 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
294 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
| |||
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
307 | | - | |
308 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
309 | 313 | | |
310 | 314 | | |
311 | 315 | | |
| |||
318 | 322 | | |
319 | 323 | | |
320 | 324 | | |
321 | | - | |
322 | | - | |
323 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
324 | 329 | | |
325 | 330 | | |
326 | 331 | | |
| |||
414 | 419 | | |
415 | 420 | | |
416 | 421 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
421 | 432 | | |
422 | 433 | | |
423 | 434 | | |
| |||
678 | 689 | | |
679 | 690 | | |
680 | 691 | | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
690 | 707 | | |
691 | 708 | | |
692 | 709 | | |
| |||
0 commit comments