{"record":{"id":"e34453b2c26d66a3","repo":"apache/seatunnel","slug":"failed-executesql-error-s","errorCode":null,"errorMessage":"Failed executeSql error %s","messagePattern":"Failed executeSql error (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/catalog/DorisCatalog.java","lineNumber":504,"sourceCode":"                    statement.execute(\n                            DorisCatalogUtil.getTruncateTableQuery(tablePath, partitions));\n                }\n            }\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\"Failed TRUNCATE TABLE in catalog %s\", tablePath.getFullName()),\n                    e);\n        }\n    }\n\n    public boolean isExistsData(TablePath tablePath) {\n        String tableName = tablePath.getFullName();\n        String sql = String.format(\"select * from %s limit 1;\", tableName);\n        try (PreparedStatement ps = conn.prepareStatement(sql);\n                ResultSet resultSet = ps.executeQuery()) {\n            return resultSet.next();\n        } catch (SQLException e) {\n            throw new CatalogException(String.format(\"Failed executeSql error %s\", sql), e);\n        }\n    }\n\n    @Override\n    public void executeSql(TablePath tablePath, String sql) {\n        try (PreparedStatement ps = conn.prepareStatement(sql)) {\n            ps.execute();\n        } catch (SQLException e) {\n            throw new CatalogException(String.format(\"Failed executeSql error %s\", sql), e);\n        }\n    }\n\n    @Override\n    public PreviewResult previewAction(\n            ActionType actionType, TablePath tablePath, Optional<CatalogTable> catalogTable) {\n        if (actionType == ActionType.CREATE_TABLE) {\n            checkArgument(catalogTable.isPresent(), \"CatalogTable cannot be null\");\n            return new SQLPreviewResult(","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/catalog/DorisCatalog.java#L486-L522","documentation":"DorisCatalog.isExistsData runs a `select * from <table> limit 1` to probe table existence and wraps any SQLException in a CatalogException whose message embeds the SQL that failed. It signals that the JDBC connection could not execute the probe query against Doris (bad SQL, missing table/privileges, or connection issues).","triggerScenarios":"Calling catalog.isExistsData(tablePath, conn) when the table name is malformed or quoted improperly, the table/database does not exist or is inaccessible, or the JDBC connection is broken/stale, causing SQLException on prepareStatement/executeQuery.","commonSituations":"Probing a table whose name contains characters needing quoting; catalog operations against a dropped or renamed Doris table; network/timeout between SeaTunnel and Doris FE node; insufficient SELECT privileges for the configured user.","solutions":["Verify the table exists and its full name (`db.table`) is correct via `SHOW TABLES` in Doris","Quote identifier parts correctly or ensure TablePath contains valid database and table names","Check the catalog user has SELECT privilege on the table","Test connectivity to the Doris FE query port and restart the job if the connection was stale"],"exampleFix":"// before\nString sql = String.format(\"select * from %s limit 1;\", tableName);\n// after\nString sql = String.format(\"select * from %s limit 1;\", tablePath.getDatabaseName() + \".`\" + tablePath.getTableName() + \"`\");","handlingStrategy":"try-catch","validationCode":"// verify table existence via catalog API first\nif (!catalog.databaseExists(tablePath.getDatabaseName()) || !catalog.tableExists(tablePath)) {\n    throw new IllegalStateException(\"Table missing before isExistsData: \" + tablePath.getFullName());\n}","typeGuard":"// ensure TablePath parts are non-blank before querying\nboolean validPath(TablePath p) {\n    return p.getDatabaseName() != null && !p.getDatabaseName().isBlank()\n        && p.getTableName() != null && !p.getTableName().isBlank();\n}","tryCatchPattern":"try {\n    boolean exists = catalog.isExistsData(tablePath, conn);\n} catch (CatalogException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof SQLException && \"42S02\".equals(((SQLException) cause).getSQLState())) {\n        // table does not exist\n    } else {\n        throw e; // connectivity/privilege problem\n    }\n}","preventionTips":["Check tableExists before probing data","Quote identifiers containing special characters","Validate FE connectivity before catalog operations","Ensure the catalog user has SELECT privileges"],"tags":["jdbc","doris","catalog","sql"],"backgroundTag":"database-query-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"}