{"record":{"id":"7f406f458adc29b3","repo":"jd-opensource/joyagent-jdgenie","slug":"s","errorCode":null,"errorMessage":"获取数据库表失败 %s ","messagePattern":"获取数据库表失败 (.+?) ","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/clickhouse/ClickhouseCatalog.java","lineNumber":36,"sourceCode":"public class ClickhouseCatalog extends AbstractJdbcCatalog {\n\n\n    @Override\n    public List<SimpleTable> listTables(Connection connection, String schema) throws CatalogException {\n        String sql = \"SELECT concat(database,'.',name) as name FROM system.tables WHERE database = '\" + schema + \"'\";\n        try (Statement prepared = connection.createStatement();\n             ResultSet rs = prepared.executeQuery(sql)) {\n            List<SimpleTable> tables = new ArrayList<>();\n            while (rs.next()) {\n                SimpleTable st = new SimpleTable();\n                st.setTableSchema(schema);\n                st.setTableName(rs.getString(\"name\"));\n                tables.add(st);\n            }\n            return tables;\n\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\"获取数据库表失败 %s \", schema), e);\n        }\n    }\n\n\n    public String getColumnType(String columnType) {\n        return switch (StandardColumnType.of(columnType)) {\n            case DECIMAL -> \"Decimal64(4)\";\n            case DATE -> \"DateTime\";\n            default -> \"String\";\n        };\n    }\n\n\n    public BigDecimal parseDecimal(String value, String fieldName) {\n        BigDecimal decimal = null;\n        if (StringUtils.isNotBlank(value)) {\n            try {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/clickhouse/ClickhouseCatalog.java#L18-L54","documentation":"ClickhouseCatalog.listTables wraps any failure while reading the table list of a ClickHouse schema into CatalogException with the message '获取数据库表失败 <schema>'. The original exception (SQL errors, connection problems, bad query) is attached as the cause. It signals that the catalog metadata query could not complete for the given schema.","triggerScenarios":"Calling listTables(schema) when the ClickHouse connection fails, the schema/database does not exist or is misspelled, or the metadata query (e.g. against system.tables) throws while iterating the ResultSet.","commonSituations":"Wrong database name passed in (case sensitivity), ClickHouse server unreachable or credentials invalid, insufficient privileges to read system tables, or driver version mismatch changing the metadata column names.","solutions":["Verify the schema/database name exists in ClickHouse (SHOW DATABASES) and is spelled correctly.","Check the ClickHouse JDBC connection (URL, user, password) is valid and the server is reachable.","Inspect the wrapped cause (e.getCause()) for the underlying SQL/IO error.","Grant the connecting user permission to read metadata tables."],"exampleFix":"// before\ncatalog.listTables(\"mydb\"); // throws CatalogException if 'mydb' misspelled\n// after\nList<SimpleTable> tables = catalog.listTables(\"my_db\"); // verify with SHOW DATABASES first","handlingStrategy":"try-catch","validationCode":"// Java: check schema is provided and non-blank before the call\nif (schema == null || schema.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"schema is required for listTables\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    List<SimpleTable> tables = catalog.listTables(schema);\n} catch (CatalogException e) {\n    log.error(\"listTables failed for schema {} cause={}\", schema, e.getCause(), e);\n    // fail fast or fall back to cached metadata\n}","preventionTips":["Always log e.getCause() — CatalogException is only a wrapper.","Validate the schema name against SHOW DATABASES output at startup.","Monitor ClickHouse connectivity before metadata queries.","Use quoted/lowercase identifiers consistently."],"tags":["jdbc","clickhouse","catalog","metadata"],"backgroundTag":"database-query-failed","analyzedSha":"2417e0b8b636d941ad5fb14c59b20dddfef5375d","analyzedAt":"2026-09-08T11:28:19.414Z","contentChangedAt":"2026-09-08T11:28:19.414Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}