This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 5110d36735 [format] Build fresh ORC writer options per created writer
(#9583)
5110d36735 is described below
commit 5110d36735b98d3444632c5941aad497680f5126
Author: YangJie <[email protected]>
AuthorDate: Fri Sep 4 03:23:33 2026 -0400
[format] Build fresh ORC writer options per created writer (#9583)
---
.../org/apache/paimon/format/orc/OrcWriterFactory.java | 11 ++++-------
.../org/apache/paimon/format/orc/OrcWriterFactoryTest.java | 14 ++++++++++++++
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git
a/paimon-format/src/main/java/org/apache/paimon/format/orc/OrcWriterFactory.java
b/paimon-format/src/main/java/org/apache/paimon/format/orc/OrcWriterFactory.java
index 948182825a..5e43c566ca 100644
---
a/paimon-format/src/main/java/org/apache/paimon/format/orc/OrcWriterFactory.java
+++
b/paimon-format/src/main/java/org/apache/paimon/format/orc/OrcWriterFactory.java
@@ -62,8 +62,6 @@ public class OrcWriterFactory implements FormatWriterFactory,
SupportsShreddingW
private final Properties writerProperties;
private final Map<String, String> confMap;
private final boolean legacyTimestampLtzType;
-
- private OrcFile.WriterOptions writerOptions;
private final int writeBatchSize;
private final MemorySize writeBatchMemory;
@@ -169,11 +167,10 @@ public class OrcWriterFactory implements
FormatWriterFactory, SupportsShreddingW
@VisibleForTesting
protected OrcFile.WriterOptions getWriterOptions() {
- if (null == writerOptions) {
- writerOptions = OrcFile.writerOptions(writerProperties,
configuration());
- writerOptions.setSchema(this.vectorizer.getSchema());
- }
-
+ // create() writes per-file state into the returned options, so it
cannot be cached.
+ OrcFile.WriterOptions writerOptions =
+ OrcFile.writerOptions(writerProperties, configuration());
+ writerOptions.setSchema(this.vectorizer.getSchema());
return writerOptions;
}
diff --git
a/paimon-format/src/test/java/org/apache/paimon/format/orc/OrcWriterFactoryTest.java
b/paimon-format/src/test/java/org/apache/paimon/format/orc/OrcWriterFactoryTest.java
index 2a0c7ab6c5..3354275a84 100644
---
a/paimon-format/src/test/java/org/apache/paimon/format/orc/OrcWriterFactoryTest.java
+++
b/paimon-format/src/test/java/org/apache/paimon/format/orc/OrcWriterFactoryTest.java
@@ -35,6 +35,7 @@ import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import static org.apache.paimon.utils.Preconditions.checkNotNull;
@@ -99,4 +100,17 @@ class OrcWriterFactoryTest {
@Override
public void addedRow(int rows) {}
}
+
+ @Test
+ void testWriterOptionsNotSharedBetweenCalls() {
+ // create() writes per-file state into the options, so each caller
needs its own.
+ OrcWriterFactory factory =
+ new OrcWriterFactory(
+ new RowDataVectorizer(
+ TypeDescription.createString(),
+ Collections.singletonList(
+ new DataField(0, "f0",
DataTypes.STRING())),
+ false));
+
assertThat(factory.getWriterOptions()).isNotSameAs(factory.getWriterOptions());
+ }
}