prestodb/presto · error · SQLException
Invalid date from server:
Error message
Invalid date from server:
What it means
getDate(columnIndex) parses the column's value as an ISO date (yyyy-MM-dd) in the session time zone using DATE_FORMATTER. If the value cannot be parsed (IllegalArgumentException), the driver throws SQLException("Invalid date from server: " + value). This means the column contained something other than a DATE-typed value, typically because the caller asked getDate on a non-date column (string, timestamp, varchar).
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:271
public Date getDate(int columnIndex)
throws SQLException
{
return getDate(columnIndex, sessionTimeZone);
}
private Date getDate(int columnIndex, DateTimeZone localTimeZone)
throws SQLException
{
Object value = column(columnIndex);
if (value == null) {
return null;
}
try {
return new Date(DATE_FORMATTER.withZone(localTimeZone).parseMillis(String.valueOf(value)));
}
catch (IllegalArgumentException e) {
throw new SQLException("Invalid date from server: " + value, e);
}
}
@Override
public Time getTime(int columnIndex)
throws SQLException
{
return getTime(columnIndex, sessionTimeZone);
}
private Time getTime(int columnIndex, DateTimeZone localTimeZone)
throws SQLException
{
Object value = column(columnIndex);
if (value == null) {
return null;
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the column type in the query result and call the matching getter (getString, getTimestamp, getDate accordingly)
- If the value is a timestamp string, either cast to DATE in SQL (CAST(col AS DATE)) or read it with getTimestamp
- Reference columns by name/alias rather than index to survive SELECT-list changes
- Validate/normalize VARCHAR date text in SQL (date_parse/coalesce) before the driver parses it
Example fix
// before
Date d = rs.getDate("created_at"); // created_at is TIMESTAMP -> throws
// after
Date d = rs.getDate("created_date"); // a CAST(created_at AS DATE) AS created_date column Defensive patterns
Strategy: type-guard
Validate before calling
ResultSetMetaData md = rs.getMetaData();
if (md.getColumnType(colIdx) == Types.DATE) {
Date d = rs.getDate(colIdx);
} Type guard
Date safeGetDate(ResultSet rs, String col) throws SQLException {
ResultSetMetaData md = rs.getMetaData();
int idx = rs.findColumn(col);
if (md.getColumnType(idx) != Types.DATE) return null; // not a DATE column
return rs.getDate(idx);
} Try / catch
catch (SQLException e) {
if (e.getMessage().startsWith("Invalid date from server")) {
// fall back to getString and parse defensively, or fix the column type
String raw = rs.getString(col);
}
throw e;
} Prevention
- Call getDate only on DATE-typed columns; use getTimestamp/getObject for TIMESTAMP and getString for VARCHAR
- Check ResultSetMetaData column types before choosing a getter
- Reference columns by alias/name, not positional index, to survive SELECT-list edits
- CAST or normalize non-DATE values in SQL before the driver parses them
When it happens
Trigger: Calling getDate on a column that is not of Presto type DATE — e.g. a VARCHAR holding arbitrary text, a TIMESTAMP value, or NULL-formatted/nonstandard text produced by the query (getDate(int, Calendar) delegates to the same code path).
Common situations: Schema drift after a table column changed from DATE to VARCHAR/TIMESTAMP; using column position after changing the SELECT list; timestamps with time components or strings like '2024-01-01T00:00:00' fed to getDate; dynamic queries where column order is not guaranteed.
Related errors
- Expected column to be a timestamp type but is
- Value is not a number:
- No wrapper for
- Result set type must be TYPE_FORWARD_ONLY
- Result set concurrency must be CONCUR_READ_ONLY
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/3028347c80c5208b.
Report an issue: GitHub.