Skip to content

Commit db3323e

Browse files
authored
Distinguish Arrow schema parsing failures from generic ResultSet errors (#1443)
## Summary Arrow IPC schema deserialization failures on the Thrift metadata path (`DatabricksThriftUtil.extractTypesFromArrowSchema`) previously surfaced as the generic `RESULT_SET_ERROR` (vendor code `1004`) with the enum name `"RESULT_SET_ERROR"` stuffed into the SQLSTATE field. That made the failure indistinguishable in telemetry and in `SQLException.getSQLState()` / `getErrorCode()` from unrelated ResultSet-shape mismatches (`executeQuery` vs `executeUpdate`, column-not-found, etc.). This PR gives the failure its own driver error code and a proper SQLSTATE: - Adds `DatabricksDriverErrorCode.ARROW_SCHEMA_PARSING_ERROR` (vendor code `22000`). - Adds `DATA_EXCEPTION_SQLSTATE = "22000"` constant in `DatabricksJdbcConstants`. - Updates the call site in `DatabricksThriftUtil.java:427` to throw with SQLSTATE `22000` (Data Exception, per [Databricks SQLSTATE docs](https://docs.databricks.com/aws/en/error-messages/sqlstates)) and the new internal code. Notes on the value `22000`: - Mirrors the SQLSTATE so the vendor code and SQLSTATE are self-documenting and aligned. - Sits well outside the MySQL/SQL Server vendor-code collision range (e.g., MySQL `1045` = "Access denied"), unlike a sequential `1045` slot in the existing enum. The thrown exception's message is unchanged. The exception chain (`cause`) is preserved. ## Test plan - [ ] CI build/test green - [ ] Manual verification: simulate a malformed Arrow schema response on the Thrift metadata path and confirm `SQLException.getSQLState()` is `"22000"` and `getErrorCode()` is `22000` - [ ] Telemetry: confirm the new error code surfaces as `ARROW_SCHEMA_PARSING_ERROR` rather than `RESULT_SET_ERROR` Signed-off-by: samikshya-chand_data <samikshya.chand@databricks.com>
1 parent a0cee89 commit db3323e

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
### Updated
1616
- `EnableGeoSpatialSupport` no longer requires `EnableComplexDatatypeSupport=1`. Geospatial types (GEOMETRY, GEOGRAPHY) can now be enabled independently of complex type support (ARRAY, MAP, STRUCT).
17+
- Arrow schema deserialization failures (Thrift metadata path) now surface a dedicated driver error code `ARROW_SCHEMA_PARSING_ERROR` (vendor code `22000`) and a proper SQLSTATE `22000` (Data Exception) on the thrown `SQLException`, instead of the generic `RESULT_SET_ERROR` (1004) and the enum name as SQLSTATE. The exception message is unchanged.
1718

1819
### Fixed
1920

src/main/java/com/databricks/jdbc/common/DatabricksJdbcConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public final class DatabricksJdbcConstants {
116116
/** Standard SQL state for communication link failure (SQLSTATE 08S01). */
117117
public static final String COMMUNICATION_LINK_FAILURE_SQLSTATE = "08S01";
118118

119+
/** Standard SQL state for data exception (SQLSTATE 22000). */
120+
public static final String DATA_EXCEPTION_SQLSTATE = "22000";
121+
119122
public static final int TEMPORARY_REDIRECT_STATUS_CODE = 307;
120123
public static final String REDACTED_TOKEN = "****";
121124
public static final String QUERY_TAGS = "query_tags";

src/main/java/com/databricks/jdbc/common/util/DatabricksThriftUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.databricks.jdbc.common.util;
22

33
import static com.databricks.jdbc.common.DatabricksJdbcConstants.ARROW_METADATA_KEY;
4+
import static com.databricks.jdbc.common.DatabricksJdbcConstants.DATA_EXCEPTION_SQLSTATE;
45
import static com.databricks.jdbc.common.DatabricksJdbcConstants.QUERY_EXECUTION_TIMEOUT_SQLSTATE;
56
import static com.databricks.jdbc.common.EnvironmentVariables.DEFAULT_RESULT_ROW_LIMIT;
67
import static com.databricks.jdbc.common.util.DatabricksTypeUtil.*;
@@ -424,7 +425,11 @@ public static List<String> getArrowMetadata(TGetResultSetMetadataResp metadata)
424425
} catch (IOException e) {
425426
String errorMessage = "Failed to deserialize Arrow schema: " + e.getMessage();
426427
LOGGER.error(errorMessage, e);
427-
throw new DatabricksSQLException(errorMessage, e, DatabricksDriverErrorCode.RESULT_SET_ERROR);
428+
throw new DatabricksSQLException(
429+
errorMessage,
430+
DATA_EXCEPTION_SQLSTATE,
431+
DatabricksDriverErrorCode.ARROW_SCHEMA_PARSING_ERROR.getCode(),
432+
e);
428433
}
429434
}
430435
}

src/main/java/com/databricks/jdbc/model/telemetry/enums/DatabricksDriverErrorCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public enum DatabricksDriverErrorCode {
4444
TRANSACTION_SET_AUTOCOMMIT_ERROR(1041),
4545
TRANSACTION_COMMIT_ERROR(1042),
4646
TRANSACTION_ROLLBACK_ERROR(1043),
47-
RATE_LIMIT_EXCEEDED(1044);
47+
RATE_LIMIT_EXCEEDED(1044),
48+
ARROW_SCHEMA_PARSING_ERROR(22000);
4849

4950
private final int code;
5051

0 commit comments

Comments
 (0)