Skip to content

Treat Hive schema errors as EXTERNAL#22893

Merged
dain merged 2 commits intotrinodb:masterfrom
dekimir:timestamp-format-external
Aug 4, 2024
Merged

Treat Hive schema errors as EXTERNAL#22893
dain merged 2 commits intotrinodb:masterfrom
dekimir:timestamp-format-external

Conversation

@dekimir
Copy link
Copy Markdown
Contributor

@dekimir dekimir commented Jul 31, 2024

Description

HiveFormatUtils sometimes throw exceptions upon encountering schema errors. These are not TrinoExceptions, so they get automatically converted to GENERIC_INTERNAL_ERROR code by QueryStateMachine. This is not correct, as the error is external, coming from the Hive table schema.

Fix it by throwing TrinoException in those cases, with a new error code for Hive schema problems.

Additional context and related issues

The new error code was added in the Hive plugin, where the HiveErrorCode enum lives. This is, unfortunately, not visible from io.trino.hive.formats, so I added a new exception type there and tried to catch it along all call-chains in the Hive plugin to convert it to the new error code.

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

# Section
* Report Hive schema problems as an EXTERNAL ErrorType, not INTERNAL_ERROR.

@cla-bot cla-bot bot added the cla-signed label Jul 31, 2024
@dekimir dekimir requested review from dain and electrum and removed request for electrum July 31, 2024 14:01
@github-actions github-actions bot added the hive Hive connector label Jul 31, 2024
@dekimir dekimir requested a review from electrum July 31, 2024 14:01
@electrum
Copy link
Copy Markdown
Member

The exception catching and wrapping turned out to be fairly messy. Can you try an alternate version that throws TrinoException directly? We can have a HiveFormatsErrorCode that contains HIVE_INVALID_METADATA. See MetastoreErrorCode for an example.

@dekimir dekimir force-pushed the timestamp-format-external branch from cc3f2e3 to 7eee758 Compare July 31, 2024 21:21
@dekimir
Copy link
Copy Markdown
Contributor Author

dekimir commented Jul 31, 2024

try an alternate version that throws TrinoException directly

Done.

Copy link
Copy Markdown
Member

@electrum electrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like this better. @dain thoughts?

@dekimir dekimir force-pushed the timestamp-format-external branch from 7eee758 to 77225a0 Compare August 1, 2024 16:47
We were previously throwing IllegalArgumentException, which is turned into a GENERIC_INTERNAL_ERROR by QueryStateMachine.  That's wrong, as the error is external.
@dekimir dekimir force-pushed the timestamp-format-external branch from 77225a0 to a45c069 Compare August 1, 2024 16:55
@dekimir
Copy link
Copy Markdown
Contributor Author

dekimir commented Aug 2, 2024

CI failure is #22861

@dain dain merged commit 1d5884d into trinodb:master Aug 4, 2024
@github-actions github-actions bot added this to the 454 milestone Aug 4, 2024
@colebow
Copy link
Copy Markdown
Member

colebow commented Aug 7, 2024

Just for reference, we generally don't document error messaging improvements in release notes - users who encounter the errors will have all the information/documentation they need when those errors arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed hive Hive connector

Development

Successfully merging this pull request may close these issues.

4 participants