{"record":{"id":"7ab952506b67485a","repo":"apache/flink","slug":"streaming-mode-not-support-overwrite","errorCode":null,"errorMessage":"Streaming mode not support overwrite.","messagePattern":"Streaming mode not support overwrite\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemTableSink.java","lineNumber":158,"sourceCode":"            @Override\n            public DataStreamSink<?> consumeDataStream(\n                    ProviderContext providerContext, DataStream<RowData> dataStream) {\n                return consume(providerContext, dataStream, sinkContext);\n            }\n        };\n    }\n\n    private DataStreamSink<?> consume(\n            ProviderContext providerContext, DataStream<RowData> dataStream, Context sinkContext) {\n        final int inputParallelism = dataStream.getParallelism();\n        final int parallelism = Optional.ofNullable(configuredParallelism).orElse(inputParallelism);\n        boolean parallelismConfigued = configuredParallelism != null;\n\n        if (sinkContext.isBounded()) {\n            return createBatchSink(dataStream, sinkContext, parallelism, parallelismConfigued);\n        } else {\n            if (overwrite) {\n                throw new IllegalStateException(\"Streaming mode not support overwrite.\");\n            }\n\n            return createStreamingSink(\n                    providerContext, dataStream, sinkContext, parallelism, parallelismConfigued);\n        }\n    }\n\n    private RowDataPartitionComputer partitionComputer() {\n        return new RowDataPartitionComputer(\n                defaultPartName,\n                DataType.getFieldNames(physicalRowDataType).toArray(new String[0]),\n                DataType.getFieldDataTypes(physicalRowDataType).toArray(new DataType[0]),\n                partitionKeys.toArray(new String[0]));\n    }\n\n    private DataStreamSink<RowData> createBatchSink(\n            DataStream<RowData> inputStream,\n            Context sinkContext,","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemTableSink.java#L140-L176","documentation":"FileSystemTableSink.consume checks the execution mode. If the source is unbounded (streaming, sinkContext.isBounded() returns false) and overwrite mode is enabled, it throws an IllegalStateException. Overwrite mode replaces all existing data in the output directory, which is only meaningful and safe in batch (bounded) execution. In streaming, data continuously arrives so overwrite semantics are undefined.","triggerScenarios":"The table sink is configured with overwrite=true (via the DynamicTableSink API or factory) and the job runs in STREAMING mode. The overwrite flag is set when consuming an unbounded (continuous) data stream.","commonSituations":"A batch pipeline that was originally bounded is changed to streaming without removing overwrite. Using INSERT OVERWRITE semantics on a filesystem sink with an unbounded source (e.g. Kafka). SQL INSERT OVERWRITE on a streaming table.","solutions":["Use BATCH execution mode if overwrite is needed: set execution.runtime-mode = BATCH.","Remove the overwrite flag if streaming execution is required — use INSERT INTO instead of INSERT OVERWRITE.","Ensure the input source is bounded (e.g. FileSource in batch mode) when using overwrite."],"exampleFix":"-- before (streaming + overwrite -> fails)\nSET 'execution.runtime-mode' = 'streaming';\nINSERT OVERWRITE sink_t SELECT * FROM kafka_source;\n\n-- after\nSET 'execution.runtime-mode' = 'batch';\nINSERT OVERWRITE sink_t SELECT * FROM batch_source;","handlingStrategy":"validation","validationCode":"// Before using overwrite on a filesystem sink, verify execution mode\nboolean isStreaming = !sinkContext.isBounded();\nif (overwrite && isStreaming) {\n    throw new IllegalStateException(\n        \"Overwrite mode is not supported in streaming execution. Use BATCH mode.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use INSERT OVERWRITE with filesystem sinks in BATCH execution mode.","Verify the source is bounded before enabling overwrite.","Use INSERT INTO (not INSERT OVERWRITE) for streaming pipelines to filesystem sinks.","Document overwrite mode restrictions in pipeline design documentation."],"tags":["table-sink","overwrite","streaming-mode","illegal-state","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}