prestodb/presto · error · IllegalArgumentException
Table %s does not have column %s
Error message
Table %s does not have column %s
What it means
TpcdsMetadata.getColumnMetadata looks up a column by name in a TPC-DS table's metadata and throws IllegalArgumentException when no column matches. It is a safeguard indicating the caller requested metadata for a column that does not exist in the named TPC-DS table.
Source
Thrown at presto-tpcds/src/main/java/com/facebook/presto/tpcds/TpcdsMetadata.java:187
ImmutableMap.Builder<String, ColumnHandle> builder = ImmutableMap.builder();
for (ColumnMetadata columnMetadata : getTableMetadata(session, tableHandle).getColumns()) {
builder.put(columnMetadata.getName(), new TpcdsColumnHandle(columnMetadata.getName(), columnMetadata.getType()));
}
return builder.build();
}
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle)
{
ConnectorTableMetadata tableMetadata = getTableMetadata(session, tableHandle);
String columnName = ((TpcdsColumnHandle) columnHandle).getColumnName();
for (ColumnMetadata column : tableMetadata.getColumns()) {
if (column.getName().equals(columnName)) {
return column;
}
}
throw new IllegalArgumentException(format("Table %s does not have column %s", tableMetadata.getTable(), columnName));
}
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> tableColumns = ImmutableMap.builder();
for (String schemaName : getSchemaNames(session, Optional.ofNullable(prefix.getSchemaName()))) {
for (Table tpcdsTable : Table.getBaseTables()) {
if (prefix.getTableName() == null || tpcdsTable.getName().equals(prefix.getTableName())) {
ConnectorTableMetadata tableMetadata = getTableMetadata(session, schemaName, tpcdsTable, useVarcharType);
tableColumns.put(new SchemaTableName(schemaName, tpcdsTable.getName()), tableMetadata.getColumns());
}
}
}
return tableColumns.build();
}
@OverrideView on GitHub (pinned to 55bb57d202)
Solutions
- Verify the column name spelling and case against the TPC-DS table definition
- Re-list columns with listTableColumns/getColumnFields instead of assuming names
- Obtain ColumnHandle values from the connector rather than constructing them manually
- Restart/rebuild the catalog if handles are stale after a version upgrade
Example fix
// before ColumnHandle h = metadata.getColumnMetadata(session, table, "natin"); // after ColumnHandle h = metadata.getColumnMetadata(session, table, "nation");
Defensive patterns
Strategy: validation
Validate before calling
Set<String> cols = metadata.listTableColumns(session, prefix).get(tableName).stream()
.map(ColumnMetadata::getName).collect(Collectors.toSet());
if (!cols.contains(columnName)) throw new IllegalArgumentException("Unknown column " + columnName + " in " + tableName); Try / catch
try {
ColumnMetadata cm = metadata.getColumnMetadata(session, tableHandle, columnName);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Table ") && e.getMessage().contains("does not have column")) {
// re-list columns and retry with corrected name
} else { throw e; }
} Prevention
- Always obtain column names from listTableColumns rather than hardcoding
- Respect exact case of TPC-DS column names
- Re-derive table/column handles after connector upgrades
When it happens
Trigger: Calling connector getColumnMetadata (via getColumnMetadata session API) with a columnName that does not exactly match any column of the given table handle, e.g. after a stale or hand-built ColumnHandle.
Common situations: Case-sensitive name mismatch ('col' vs 'Col'); using a column name from a different TPC-DS table; stale serialized table/column handles after connector upgrade.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/d32319487cadf131.
Report an issue: GitHub.