apache/druid · error · ResultSetException
Unable to access specific metadata from result set metadata
Error message
Unable to access specific metadata from result set metadata
What it means
After obtaining ResultSetMetaData, SqlEntity.openCleanableFile() reads each column's name, label, and value inside a loop. Any SQLException thrown while accessing per-column metadata or row values (getColumnName/getColumnLabel/getObject) is wrapped in a ResultSetException with the message 'Unable to access specific metadata from result set metadata'.
Solutions
- Inspect the wrapped SQLException cause for the failing column index and fix the query or aliasing.
- Check connection stability/timeouts for large result fetches; increase socket and query timeouts.
- Avoid exotic column types in the SQL projection that the JDBC driver cannot map via getObject().
- Upgrade the JDBC driver if column-label handling is known-buggy.
Example fix
// before SELECT weird_json_col FROM table // after SELECT CAST(weird_json_col AS VARCHAR) AS weird_json_col FROM table
Defensive patterns
Strategy: try-catch
Validate before calling
// check connection validity and statement state before streaming
if (!connection.isValid(5)) { reconnect(); } Try / catch
try {
sqlEntity.fetch(tempDir, buffer);
} catch (ResultSetException e) {
SQLException sql = (SQLException) e.getCause();
// log sql.getErrorCode()/getSQLState(); retry with backoff if transient
} Prevention
- Avoid exotic column types in SQL projections
- Increase timeouts for large result streams
- Use stable column aliases to avoid null-label driver quirks
When it happens
Trigger: A SQLException during row iteration: invalid column index, connection dropped mid-iteration, type conversion failure in getObject(i), or driver refusing column label/name access.
Common situations: Large result sets where the connection times out partway through streaming; column aliasing issues with certain drivers returning null labels; driver bugs with specific column types (e.g., complex/JSON types).
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Unable to obtain metadata from result set
- 08001
- argument must be a LONG constant
- Cannot create JDBC driver of class
- Cannot filter datasource
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/4124f5c4d0e2d7b0.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/main/java/org/apache/druid/metadata/input/SqlEntity.java:150
(index, r, ctx) -> {
Map<String, Object> resultRow = foldCase ? new CaseFoldedMap() : new HashMap<>();
ResultSetMetaData resultMetadata;
try {
resultMetadata = r.getMetaData();
}
catch (SQLException e) {
throw new ResultSetException("Unable to obtain metadata from result set", e, ctx);
}
try {
for (int i = 1; i <= resultMetadata.getColumnCount(); i++) {
String key = resultMetadata.getColumnName(i);
String alias = resultMetadata.getColumnLabel(i);
Object value = r.getObject(i);
resultRow.put(alias != null ? alias : key, value);
}
}
catch (SQLException e) {
throw new ResultSetException("Unable to access specific metadata from " +
"result set metadata", e, ctx);
}
return resultRow;
}
).iterator();
jg.writeStartArray();
while (resultIterator.hasNext()) {
JacksonUtils.writeObjectUsingSerializerProvider(jg, serializers, resultIterator.next());
}
jg.writeEndArray();
jg.close();
return null;
},
(exception) -> sqlInputSourceDatabaseConnector.isTransientException(exception)
&& !(SQLMetadataConnector.isStatementException(exception))
);
return new CleanableFile()
{View on GitHub (pinned to 9b90983fd2)