Repository navigation
Return empty primary-key metadata for missing objects in Thrift #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vuanhphung
wants to merge
1
commit into
main
Choose a base branch
from
fix/thrift-primary-keys-not-found
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { v4 } from 'uuid'; | ||
| import { TTableSchema } from '../../thrift/TCLIService_types'; | ||
| import IOperationBackend from '../contracts/IOperationBackend'; | ||
| import { OperationState, OperationStatus } from '../contracts/OperationStatus'; | ||
| import { ResultFormat, ResultMetadata } from '../contracts/ResultMetadata'; | ||
| import Status from '../dto/Status'; | ||
|
|
||
| export default class EmptyOperationBackend implements IOperationBackend { | ||
| public readonly id = v4(); | ||
|
|
||
| constructor(private readonly schema: TTableSchema) {} | ||
|
|
||
| public hasResultSet(): boolean { | ||
| return true; | ||
| } | ||
|
|
||
| public async fetchChunk(): Promise<Array<object>> { | ||
| return []; | ||
| } | ||
|
|
||
| public async hasMore(): Promise<boolean> { | ||
| return false; | ||
| } | ||
|
|
||
| public async waitUntilReady(): Promise<void> { | ||
| return undefined; | ||
| } | ||
|
|
||
| public async status(): Promise<OperationStatus> { | ||
| return { state: OperationState.Succeeded, hasResultSet: true }; | ||
| } | ||
|
|
||
| public async getResultMetadata(): Promise<ResultMetadata> { | ||
| return { schema: this.schema, resultFormat: ResultFormat.ColumnBased, isStagingOperation: false }; | ||
| } | ||
|
|
||
| public async cancel(): Promise<Status> { | ||
| return Status.success(); | ||
| } | ||
|
|
||
| public async close(): Promise<Status> { | ||
| return Status.success(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| interface MetadataError { | ||
| sqlState?: string | null; | ||
| errorMessage?: string | null; | ||
| displayMessage?: string | null; | ||
| } | ||
|
|
||
| export default function isObjectNotFound(error: MetadataError): boolean { | ||
| // Match Databricks JDBC's metadata not-found classification. | ||
| return ( | ||
| error.sqlState === '42704' || | ||
| [error.errorMessage, error.displayMessage].some((message) => | ||
| ['NO_SUCH_CATALOG_EXCEPTION', 'SCHEMA_NOT_FOUND', 'TABLE_OR_VIEW_NOT_FOUND', 'INVALID_PARAMETER_VALUE'].some( | ||
| (errorClass) => message?.includes(errorClass), | ||
| ), | ||
| ) | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { TTableSchema, TTypeId } from '../../thrift/TCLIService_types'; | ||
|
|
||
| const primaryKeysSchema: TTableSchema = { | ||
| columns: ['TABLE_CAT', 'TABLE_SCHEM', 'TABLE_NAME', 'COLUMN_NAME', 'KEY_SEQ', 'PK_NAME'].map((columnName, index) => ({ | ||
| columnName, | ||
| typeDesc: { | ||
| types: [{ primitiveEntry: { type: columnName === 'KEY_SEQ' ? TTypeId.INT_TYPE : TTypeId.STRING_TYPE } }], | ||
| }, | ||
| position: index + 1, | ||
| comment: '', | ||
| })), | ||
| }; | ||
|
|
||
| export default primaryKeysSchema; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 Low —
isObjectNotFoundclassifies any error whoseerrorMessage/displayMessagecontains the substringINVALID_PARAMETER_VALUEas "object not found", which is broader than missing catalog/schema/table. ForgetPrimaryKeys, Spark raisesINVALID_PARAMETER_VALUEfor several non-missing-object conditions (e.g. a malformed/empty identifier argument). Because this classifier gates the empty-result recovery for primary keys (both inThriftSessionBackend.getPrimaryKeysand viaemptyResultOnNotFoundinThriftOperationBackend.processOperationStatusResponse), such a genuine invalid-argument failure would be silently converted into a successful empty result set instead of surfacing to the caller.The match is deliberately scoped to primary-key metadata and mirrors JDBC, so this is low severity — but it's worth confirming JDBC actually anchors on the error class (not a loose substring) and, if so, tightening the match (e.g. require it to co-occur with the
42704/42P01SQLSTATE, or match the bracketed[INVALID_PARAMETER_VALUE]prefix the tests use) so unrelated invalid-parameter errors still propagate.