public class TableWriteSessionBuilder extends Object
This builder allows configuration of various write session settings including:
Example usage:
TableIdentifier tableId = TableIdentifier.of("my_project", "my_table");
TableWriteSessionBuilder builder = client.createWriteSessionBuilder(tableId)
.withPartition(new PartitionSpec("pt='20250101'"))
.withOverwrite(true);
TableWriteSession session = builder.build();
Streaming mode example:
TableIdentifier tableId = TableIdentifier.of("my_project", "my_table");
TableWriteSessionBuilder builder = client.createWriteSessionBuilder(tableId)
.withWriteMode(WriteMode.STREAMING);
TableWriteSession session = builder.build();
| Constructor and Description |
|---|
TableWriteSessionBuilder(StorageStub storageStub,
org.apache.arrow.memory.BufferAllocator allocator,
TableIdentifier table)
Constructs a new TableWriteSessionBuilder with the provided parameters.
|
| Modifier and Type | Method and Description |
|---|---|
TableWriteSession |
build()
Builds and returns a new TableWriteSession instance with the configured settings.
|
TableWriteSessionBuilder |
withOverwrite(boolean overwrite)
Sets whether to overwrite existing data when writing to the table.
|
TableWriteSessionBuilder |
withPartition(PartitionSpec partitionSpec)
Sets the partition specification for writing data to a specific partition.
|
TableWriteSessionBuilder |
withSessionId(String sessionId)
Set the sessionId to reload write session.
|
TableWriteSessionBuilder |
withWriteMode(WriteMode writeMode)
Sets the write mode for the session.
|
public TableWriteSessionBuilder(StorageStub storageStub, org.apache.arrow.memory.BufferAllocator allocator, TableIdentifier table)
storageStub - The storage stub for communicating with the MaxCompute serviceallocator - The buffer allocator for Arrow memory managementtable - The identifier of the table to write toIllegalArgumentException - if table is nullpublic TableWriteSessionBuilder withSessionId(String sessionId)
sessionId - The session id of write session already created.public TableWriteSessionBuilder withPartition(PartitionSpec partitionSpec)
This allows writing data to a specific partition value, which is useful for partitioned tables.
partitionSpec - The partition specification to write topublic TableWriteSessionBuilder withOverwrite(boolean overwrite)
When overwrite is enabled, existing data in the table or specified partitions will be replaced with the new data being written.
overwrite - Whether to overwrite existing datapublic TableWriteSessionBuilder withWriteMode(WriteMode writeMode)
In BATCH mode (default), data becomes visible only after the session is committed. In STREAMING mode, data becomes visible immediately after flush, without requiring explicit commit. Streaming mode uses a default session ID and does not require explicit session creation.
writeMode - The write mode to use (BATCH or STREAMING)public TableWriteSession build()
For BATCH mode, this method makes an API call to the MaxCompute service to create a write session with the specified configuration.
For STREAMING mode, no session creation API call is made. The session uses a default session ID ("default") and data becomes visible immediately after flush.
Copyright © 2026 Alibaba Cloud Computing. All rights reserved.