Skip to content

Commit 3d8ac30

Browse files
committed
[SEA-NodeJS] map kernel SqlError to OperationStateError for Thrift parity
Server-reported SQL execution failures (kernel `SqlError` — bad query, missing table, divide-by-zero, invalid cast, param type mismatch) were surfaced as the base `HiveDriverError` on the SEA/kernel path, while the Thrift backend raises `OperationStateError(Error)` when the operation reaches ERROR_STATE. The comparator flagged every error path as a class mismatch (Thrift `OperationStateError` vs SEA `HiveDriverError`), and the Python kernel connector matches Thrift here — so the divergence was in this mapping, not the kernel. Map `SqlError` -> `OperationStateError(OperationStateErrorCode.Error)`, preserving the kernel message. `OperationStateError extends HiveDriverError`, so existing `instanceof HiveDriverError` catches are unaffected. Other code mappings (InvalidArgument -> ParameterError, auth, network, etc.) are unchanged. Verified against the comparator warehouse: all ERROR_PATHS cases (table-not-found, syntax error, unresolved column, divide-by-zero, invalid cast, param mismatch) now match the Thrift backend. Co-authored-by: Isaac
1 parent 4b9e16e commit 3d8ac30

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

lib/sea/SeaErrorMapping.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ export function mapKernelErrorToJsError(kErr: KernelErrorShape): ErrorWithSqlSta
147147
error = new ParameterError(message);
148148
break;
149149

150+
case 'SqlError': {
151+
// A server-reported SQL execution failure (kernel `SqlError`, e.g. a
152+
// bad query, missing table, divide-by-zero, invalid cast). The Thrift
153+
// backend surfaces the same situation as `OperationStateError(Error)`
154+
// when the operation reaches ERROR_STATE (see DBSQLOperation), so map
155+
// SqlError to the same class for backend parity. OperationStateError
156+
// extends HiveDriverError, so existing `instanceof HiveDriverError`
157+
// catches are unaffected.
158+
const stateError = new OperationStateError(OperationStateErrorCode.Error);
159+
stateError.message = message;
160+
error = stateError;
161+
break;
162+
}
163+
150164
// All remaining kernel ErrorCode variants map to the base driver error class.
151165
// M0 intentionally does not introduce new error classes; M1 may add nuance.
152166
case 'NotFound':
@@ -156,7 +170,6 @@ export function mapKernelErrorToJsError(kErr: KernelErrorShape): ErrorWithSqlSta
156170
case 'Internal':
157171
case 'InvalidStatementHandle':
158172
case 'NetworkError':
159-
case 'SqlError':
160173
error = new HiveDriverError(message);
161174
break;
162175

0 commit comments

Comments
 (0)