{"record":{"id":"0e80809993f3470e","repo":"prestodb/presto","slug":"table-s-does-not-have-column-s-0e8080","errorCode":null,"errorMessage":"Table %s does not have column %s","messagePattern":"Table (.+?) does not have column (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-tpch/src/main/java/com/facebook/presto/tpch/TpchMetadata.java","lineNumber":476,"sourceCode":"\n    @VisibleForTesting\n    TpchColumnHandle toColumnHandle(TpchColumn<?> column)\n    {\n        return new TpchColumnHandle(columnNaming.getName(column), getPrestoType(column));\n    }\n\n    @Override\n    public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle)\n    {\n        ConnectorTableMetadata tableMetadata = getTableMetadata(session, tableHandle);\n        String columnName = ((TpchColumnHandle) columnHandle).getColumnName();\n\n        for (ColumnMetadata column : tableMetadata.getColumns()) {\n            if (column.getName().equals(columnName)) {\n                return column;\n            }\n        }\n        throw new IllegalArgumentException(String.format(\"Table %s does not have column %s\", tableMetadata.getTable(), columnName));\n    }\n\n    @Override\n    public List<SchemaTableName> listTables(ConnectorSession session, Optional<String> filterSchema)\n    {\n        ImmutableList.Builder<SchemaTableName> builder = ImmutableList.builder();\n        for (String schemaName : getSchemaNames(session, filterSchema)) {\n            for (TpchTable<?> tpchTable : TpchTable.getTables()) {\n                builder.add(new SchemaTableName(schemaName, tpchTable.getTableName()));\n            }\n        }\n        return builder.build();\n    }\n\n    private TupleDomain<ColumnHandle> toTupleDomain(Map<TpchColumnHandle, Set<NullableValue>> predicate)\n    {\n        return TupleDomain.withColumnDomains(predicate.entrySet().stream()\n                .collect(Collectors.toMap(Map.Entry::getKey, entry -> {","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-tpch/src/main/java/com/facebook/presto/tpch/TpchMetadata.java#L458-L494","documentation":"TpchMetadata.getColumnMetadata scans the TPC-H table metadata for a column matching the requested name and throws IllegalArgumentException 'Table %s does not have column %s' when none matches. It indicates the caller supplied a column name/handle that does not exist in the given TPC-H table.","triggerScenarios":"Calling connector getColumnMetadata with a columnName absent from the table's metadata, e.g. a ColumnHandle from a different table, a misnamed column, or a stale handle after version change.","commonSituations":"Case mismatch in column name (TPC-H columns are lowercase like 'nationkey'); using a column from lineitem on an orders table handle; deserialized handles from an older Presto version.","solutions":["Verify the exact column name against the TPC-H table (e.g. 'nationkey', not 'nationKey')","List actual columns via listTableColumns before lookup","Re-acquire ColumnHandle objects from the connector metadata instead of caching across restarts/upgrades","Check that the table handle refers to the intended table"],"exampleFix":"// before\nmetadata.getColumnMetadata(session, ordersHandle, \"totalprice2\");\n// after\nmetadata.getColumnMetadata(session, ordersHandle, \"totalprice\");","handlingStrategy":"validation","validationCode":"Set<String> cols = metadata.listTableColumns(session, SchemaTablePrefix.of(schema, table)).get(SchemaTableName.of(schema, table))\n    .stream().map(ColumnMetadata::getName).collect(Collectors.toSet());\nif (!cols.contains(columnName)) throw new IllegalArgumentException(\"Column \" + columnName + \" not in \" + table);","typeGuard":null,"tryCatchPattern":"try {\n    ColumnMetadata cm = metadata.getColumnMetadata(session, tableHandle, columnName);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"does not have column\")) {\n        // fall back to listing columns and matching case-insensitively\n    } else { throw e; }\n}","preventionTips":["Use lowercase column names for TPC-H tables (nationkey, totalprice)","Never reuse ColumnHandle across tables or Presto versions","Discover columns dynamically instead of hardcoding names"],"tags":["metadata","tpch","column-not-found"],"backgroundTag":"column-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}