{"record":{"id":"41249f89abf0432a","repo":"apache/seatunnel","slug":"failed-to-query-table-schema","errorCode":null,"errorMessage":"Failed to query table schema: {}","messagePattern":"Failed to query table schema: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/sink/DatabendSinkWriter.java","lineNumber":584,"sourceCode":"\n                while (rs.next()) {\n                    String columnName = rs.getString(\"Field\");\n                    String columnType = rs.getString(\"Type\");\n\n                    fieldNames.add(columnName);\n                    fieldTypes.add(convertDatabendTypeNameToSeaTunnelType(columnType));\n\n                    log.info(\"Found column: {} {}\", columnName, columnType);\n                }\n\n                if (!fieldNames.isEmpty()) {\n                    return new SeaTunnelRowType(\n                            fieldNames.toArray(new String[0]),\n                            fieldTypes.toArray(new SeaTunnelDataType<?>[0]));\n                }\n            }\n        } catch (Exception e) {\n            log.warn(\"Failed to query table schema: {}\", e.getMessage());\n        }\n        return null;\n    }\n\n    private SeaTunnelDataType<?> convertDatabendTypeNameToSeaTunnelType(String typeName) {\n        if (typeName == null) {\n            return BasicType.STRING_TYPE;\n        }\n\n        typeName = typeName.toUpperCase();\n\n        if (typeName.contains(\"VARCHAR\")\n                || typeName.contains(\"STRING\")\n                || typeName.contains(\"TEXT\")) {\n            return BasicType.STRING_TYPE;\n        } else if (typeName.contains(\"INT\") && !typeName.contains(\"BIGINT\")) {\n            return BasicType.INT_TYPE;\n        } else if (typeName.contains(\"BIGINT\")) {","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/sink/DatabendSinkWriter.java#L566-L602","documentation":"Logged by DatabendSinkWriter.queryTableSchema() when querying Databend's information/schema for the target table's columns throws any exception. The method returns null on failure, and callers fall back to schema inference. Because this is a warn (not throw), a transient query failure silently degrades the writer to inferred column names.","triggerScenarios":"The JDBC metadata query (e.g. DESC/information_schema.columns) fails: bad connection, missing SELECT privilege on information_schema, wrong database/table name, or table not yet created (auto-create race).","commonSituations":"Typo in table/database name; user lacks metadata privileges; auto_create_table enabled so the table doesn't exist yet at first schema lookup; network error to Databend.","solutions":["Verify the configured database/table names are correct and the table exists before starting the job","Grant the Databend user permission to read information_schema / describe the table","Ensure the JDBC connection URL and credentials are valid; test with a manual DESC table","Check the logged exception message for the root SQL error (only e.getMessage() is logged) and fix accordingly"],"exampleFix":"// before\n} catch (Exception e) {\n    log.warn(\"Failed to query table schema: {}\", e.getMessage());\n}\n// after\n} catch (Exception e) {\n    log.warn(\"Failed to query table schema: {}\", e.getMessage(), e);\n    throw new DatabendConnectorException(DatabendConnectorErrorCode.SCHEMA_NOT_FOUND, e);\n}","handlingStrategy":"fallback","validationCode":"// pre-check metadata access before running the job\ntry (Connection c = DriverManager.getConnection(url, user, pass);\n     Statement s = c.createStatement()) {\n    s.executeQuery(\"DESC \" + database + \".\" + table);\n}","typeGuard":"boolean schemaQueryable(String db, String tbl) {\n    try (Connection c = DriverManager.getConnection(url, user, pass);\n         Statement s = c.createStatement()) {\n        s.executeQuery(\"SELECT 1 FROM information_schema.tables WHERE table_schema='\" + db + \"' AND table_name='\" + tbl + \"' AND 1=0\");\n        return true;\n    } catch (SQLException e) { return false; }\n}","tryCatchPattern":"try {\n    SeaTunnelRowType t = queryTableSchema();\n} catch (Exception e) {\n    // writer already returns null; provide explicit schema instead of relying on inference\n}","preventionTips":["Pre-create the target table or ensure auto-create completes before schema lookup","Grant metadata privileges to the sink user","Validate database/table names in config before job submission"],"tags":["jdbc","metadata","schema","databend"],"backgroundTag":"schema-validation-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}