jd-opensource/joyagent-jdgenie · error · CatalogException
获取表字段信息失败
Error message
获取表字段信息失败 %s
What it means
MySqlCatalog.getTableColumns wraps any exception while reading column metadata for a table into CatalogException '获取表字段信息失败 <tablePath>'. The cause contains the underlying SQL error. It indicates column metadata for the given MySQL table could not be fetched.
Solutions
- Verify the table exists in the target schema (listTables first).
- Check the tablePath format matches schema.table and identifier casing.
- Inspect the wrapped cause SQLException for the MySQL error code.
- Grant the connecting user metadata read privileges.
Example fix
// before
catalog.getTableColumns("orders"); // missing schema prefix
// after
catalog.getTableColumns("shop.orders"); Defensive patterns
Strategy: validation
Validate before calling
// Java: verify the table exists before getTableColumns
List<SimpleTable> tables = mySqlCatalog.listTables(schema);
boolean exists = tables.stream().anyMatch(t -> t.getTableName().equalsIgnoreCase(tableName));
if (!exists) throw new IllegalStateException("table not found: " + tablePath); Try / catch
try {
List<Column> cols = mySqlCatalog.getTableColumns(tablePath);
} catch (CatalogException e) {
log.error("column metadata failed for {}: {}", tablePath, e.getCause().getMessage(), e);
} Prevention
- Always pass schema.table, not a bare table name.
- Run migrations and metadata reads against the same environment.
- Verify grants on information_schema.
- Check identifier casing against lower_case_table_names.
When it happens
Trigger: Calling getTableColumns(tablePath) when the table does not exist, the schema is wrong, or the information_schema query throws an SQLException.
Common situations: Typo in schema.table path, table dropped by a migration, connecting to the wrong MySQL instance/environment, or missing privileges on information_schema columns.
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
AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08).
Data as JSON: /api/errors/a1432575d4fb5a93.
Report an issue: GitHub.
Appendix: source
Thrown at genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/mysql/MySqlCatalog.java:84
List<TableColumn> columnList = new ArrayList<>();
while (rs.next()) {
String columnName = rs.getString("COLUMN_NAME");
String jdbcDataType = rs.getString("DATA_TYPE").toUpperCase();
String dataType = typeConvertMysql(jdbcDataType);
String comment = rs.getString("COLUMN_COMMENT");
TableColumn column = TableColumn.builder().name(columnName)
.comment(comment)
.dataType(dataType)
.originDataType(jdbcDataType)
.nullable(rs.getBoolean("Is_NULLABLE"))
.position(i++)
.build();
columnList.add(column);
}
return columnList;
} catch (Exception e) {
throw new CatalogException(
String.format("获取表字段信息失败 %s", tablePath), e);
}
}
}
View on GitHub (pinned to 2417e0b8b6)