{"record":{"id":"d4d625d69164c174","repo":"apache/seatunnel","slug":"failed-to-get-table-schema-from-catalog-will-try","errorCode":null,"errorMessage":"Failed to get table schema from catalog, will try to infer schema from query","messagePattern":"Failed to get table schema from catalog, will try to infer schema from query","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/source/DatabendSourceFactory.java","lineNumber":101,"sourceCode":"            String password = options.get(DatabendOptions.PASSWORD);\n            Integer fetchSize = options.get(DatabendOptions.FETCH_SIZE);\n            String sql = buildSqlStatement(options);\n\n            String catalogName = \"default\";\n            String database = options.getOptional(DATABASE).orElse(\"default\");\n            String table = options.getOptional(DatabendOptions.TABLE).orElse(\"default\");\n\n            // use catalog to get table schema\n            DatabendCatalog catalog = new DatabendCatalog(options, catalogName);\n            try {\n                catalog.open();\n                TablePath tablePath = TablePath.of(database, table);\n                CatalogTable catalogTable = catalog.getTable(tablePath);\n                log.info(\"Successfully retrieved catalog table: {}\", catalogTable);\n                return new DatabendSource(\n                        catalogTable, sql, url, ssl, username, password, fetchSize);\n            } catch (Exception e) {\n                log.warn(\n                        \"Failed to get table schema from catalog, will try to infer schema from query\",\n                        e);\n                TableSchema.Builder builder = TableSchema.builder();\n                TableSchema tableSchema = builder.build();\n                CatalogTable catalogTable =\n                        CatalogTable.of(\n                                TableIdentifier.of(catalogName, database, table),\n                                tableSchema,\n                                Collections.emptyMap(),\n                                Collections.emptyList(),\n                                \"\",\n                                catalogName);\n                return new DatabendSource(\n                        catalogTable, sql, url, ssl, username, password, fetchSize);\n            } finally {\n                try {\n                    catalog.close();\n                } catch (Exception e) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/source/DatabendSourceFactory.java#L83-L119","documentation":"In DatabendSourceFactory.createSource(), if the Databend catalog cannot return the CatalogTable for the configured database/table, the exception is caught, this warning is logged, and the factory falls back to building a CatalogTable with an empty TableSchema, letting the reader infer schema from the query results at runtime. The job still starts but with weaker typing until inference completes.","triggerScenarios":"catalog.getTable(tablePath) throws: table doesn't exist, wrong database/table name in options, JDBC connection failure, or insufficient privileges to read metadata.","commonSituations":"Typo in table or database config; table created later by the pipeline (auto-create); Databend unreachable (wrong URL/port); user lacking metadata permissions.","solutions":["Verify the table and database names in the source options exist in Databend","Check URL, username and password by connecting manually (e.g. via mysql client / Bendsql)","Grant the user metadata access on the target database","Review the attached exception stack trace for the root cause; don't rely on inference if you need exact column types"],"exampleFix":"// before\n} catch (Exception e) {\n    log.warn(\"Failed to get table schema from catalog, will try to infer schema from query\", e);\n    TableSchema.Builder builder = TableSchema.builder();\n// after\n} catch (Exception e) {\n    log.warn(\"Failed to get table schema from catalog, will try to infer schema from query\", e);\n    if (failOnMissingSchema) {\n        throw new DatabendConnectorException(DatabendConnectorErrorCode.SCHEMA_NOT_FOUND, e);\n    }\n    TableSchema.Builder builder = TableSchema.builder();","handlingStrategy":"fallback","validationCode":"// validate table existence before job submission\ntry (Connection c = DriverManager.getConnection(url, user, pass);\n     Statement s = c.createStatement()) {\n    s.executeQuery(\"SELECT 1 FROM \" + database + \".\" + table + \" LIMIT 0\");\n}","typeGuard":"boolean tableAccessible(String db, String tbl) {\n    try (Connection c = DriverManager.getConnection(url, user, pass);\n         Statement s = c.createStatement()) {\n        s.execute(\"USE \" + db);\n        s.executeQuery(\"SELECT 1 FROM \" + tbl + \" LIMIT 0\");\n        return true;\n    } catch (SQLException e) { return false; }\n}","tryCatchPattern":"try {\n    Source source = factory.createSource(context);\n} catch (Exception e) {\n    log.error(\"Source creation failed even after schema-inference fallback\", e);\n    throw e;\n}","preventionTips":["Verify database/table names and credentials in source options before submitting","Grant the user metadata privileges so catalog.getTable succeeds","Don't rely on the empty-schema fallback if exact column types matter"],"tags":["catalog","schema","fallback","databend-source"],"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-23T08:17:48.524Z"}