{"record":{"id":"b90fd63fbec3dba3","repo":"apache/seatunnel","slug":"generate-empty-file-when-no-data-is-not-supported","errorCode":null,"errorMessage":"Generate empty file when no data is not supported when partition is enabled.","messagePattern":"Generate empty file when no data is not supported when partition is enabled\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/BaseFileSink.java","lineNumber":76,"sourceCode":"\n    protected abstract HadoopConf initHadoopConf();\n\n    @Override\n    public Optional<CatalogTable> getWriteCatalogTable() {\n        return Optional.of(catalogTable);\n    }\n\n    public void preCheckConfig() {\n        if (pluginConfig.getOptional(FileBaseSinkOptions.SINGLE_FILE_MODE).isPresent()\n                && pluginConfig.get(FileBaseSinkOptions.SINGLE_FILE_MODE)\n                && jobContext.isEnableCheckpoint()) {\n            throw new IllegalArgumentException(\n                    \"Single file mode is not supported when checkpoint is enabled or in streaming mode.\");\n        }\n        if (pluginConfig.getOptional(FileBaseSinkOptions.CREATE_EMPTY_FILE_WHEN_NO_DATA).isPresent()\n                && pluginConfig.get(FileBaseSinkOptions.CREATE_EMPTY_FILE_WHEN_NO_DATA)\n                && !fileSinkConfig.getPartitionFieldList().isEmpty()) {\n            throw new IllegalArgumentException(\n                    \"Generate empty file when no data is not supported when partition is enabled.\");\n        }\n    }\n\n    @Override\n    public void setJobContext(JobContext jobContext) {\n        this.jobContext = jobContext;\n        this.jobId = jobContext.getJobId();\n        preCheckConfig();\n    }\n\n    @Override\n    public SinkWriter<SeaTunnelRow, FileCommitInfo, FileSinkState> restoreWriter(\n            SinkWriter.Context context, List<FileSinkState> states) {\n        return new BaseFileSinkWriter(createWriteStrategy(), hadoopConf, context, jobId, states);\n    }\n\n    @Override","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/BaseFileSink.java#L58-L94","documentation":"BaseFileSink.preCheckConfig rejects create_empty_file_when_no_data = true when the sink is partitioned, because generating an empty file per nonexistent partition combination is undefined; the connector throws IllegalArgumentException.","triggerScenarios":"Setting create_empty_file_when_no_data = true while sink.partition_by contains one or more fields, so fileSinkConfig.getPartitionFieldList() is non-empty during preCheckConfig.","commonSituations":"Users want empty files to signal job completion in a partitioned sink; combining two independently useful sink options without realizing they conflict; templated configs where partition fields were added later.","solutions":["Remove create_empty_file_when_no_data = true from the partitioned sink config","Remove partition_by if empty-file-on-no-data semantics are required more than partitioning","Handle 'no data' detection externally (e.g. downstream job monitoring) instead of relying on empty files"],"exampleFix":"// before\nsink {\n  LocalFile {\n    partition_by = [\"dt\"]\n    create_empty_file_when_no_data = true\n  }\n}\n// after\nsink {\n  LocalFile {\n    partition_by = [\"dt\"]\n  }\n}","handlingStrategy":"validation","validationCode":"if (config.get(\"create_empty_file_when_no_data\") == true && partitionFields != null && !partitionFields.isEmpty()) {\n    throw new IllegalArgumentException(\"create_empty_file_when_no_data cannot be used with partition_by\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat create_empty_file_when_no_data and partition_by as mutually exclusive in config templates","Validate sink option combinations before job submission"],"tags":["sink","config","partition"],"backgroundTag":"conflicting-config-options","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"}