{"record":{"id":"fdc15d9f19857127","repo":"apache/seatunnel","slug":"hudi-catalog-not-support-truncate-table","errorCode":null,"errorMessage":"Hudi catalog not support truncate table.","messagePattern":"Hudi catalog not support truncate table\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/catalog/HudiCatalog.java","lineNumber":272,"sourceCode":"            if (ignoreIfNotExists) {\n                return;\n            } else {\n                throw new TableNotExistException(catalogName, tablePath);\n            }\n        }\n\n        Path path = new Path(inferTablePath(tableParentDfsPathStr, tablePath));\n        try {\n            this.fs.delete(path, true);\n        } catch (IOException e) {\n            throw new CatalogException(String.format(\"Dropping table %s exception.\", tablePath), e);\n        }\n    }\n\n    @Override\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        throw new UnsupportedOperationException(\"Hudi catalog not support truncate table.\");\n    }\n\n    @Override\n    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        if (databaseExists(tablePath.getDatabaseName())) {\n            if (ignoreIfExists) {\n                return;\n            } else {\n                throw new DatabaseAlreadyExistException(catalogName, tablePath.getDatabaseName());\n            }\n        }\n\n        Path dbPath = new Path(tableParentDfsPath, tablePath.getDatabaseName());\n        try {\n            fs.mkdirs(dbPath);\n        } catch (IOException e) {\n            throw new CatalogException(","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/catalog/HudiCatalog.java#L254-L290","documentation":"Thrown unconditionally by HudiCatalog.truncateTable — the Hudi catalog does not implement table truncation, so any truncate request via save mode or catalog API hits this UnsupportedOperationException.","triggerScenarios":"Any call to truncateTable(tablePath, ignoreIfNotExists), e.g., a pipeline or higher-level API that clears tables before writing invokes it on a Hudi catalog.","commonSituations":"Framework-level 'truncate before load' option enabled while using the Hudi catalog; generic catalog code paths assuming all catalogs support truncate.","solutions":["Do not call truncateTable on the Hudi catalog; drop and recreate the table instead.","Delete table data via Hudi tooling (e.g., clean/rollback or overwrite write type) rather than catalog truncate.","Guard feature flags so truncate is skipped for catalogs that do not support it."],"exampleFix":"// before\ncatalog.truncateTable(tablePath, true);\n// after\nif (catalog.tableExists(tablePath)) {\n    catalog.dropTable(tablePath, true);\n    catalog.createTable(tablePath, schema, true);\n}","handlingStrategy":"type-guard","validationCode":"// Java\nif (catalog instanceof HudiCatalog) {\n    throw new UnsupportedOperationException(\"Truncate unsupported for Hudi catalog\");\n}","typeGuard":"boolean supportsTruncate = !(catalog instanceof HudiCatalog);","tryCatchPattern":"// Java\ntry {\n    catalog.truncateTable(tablePath, true);\n} catch (UnsupportedOperationException e) {\n    // fall back: drop + recreate or use Hudi overwrite/cleanup\n}","preventionTips":["Never enable framework 'truncate before load' options for Hudi sinks.","Feature-detect capability instead of assuming all catalogs support truncate.","Use dropTable + createTable as the truncation alternative.","Prefer Hudi-native data reset (overwrite insert or cleanup) for clearing data."],"tags":["hudi","unsupported-operation","catalog"],"backgroundTag":"unsupported-operation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}