3636#include " paimon/core/io/compact_increment.h"
3737#include " paimon/core/io/data_file_path_factory.h"
3838#include " paimon/core/io/data_increment.h"
39- #include " paimon/core/io/external_storage_blob_writer.h"
4039#include " paimon/core/io/multiple_blob_file_writer.h"
4140#include " paimon/core/io/rolling_blob_file_writer.h"
4241#include " paimon/core/io/rolling_file_writer.h"
@@ -85,22 +84,6 @@ Status AppendOnlyWriter::Write(std::unique_ptr<RecordBatch>&& batch) {
8584 PAIMON_ASSIGN_OR_RAISE (writer_, CreateRollingRowWriter ());
8685 }
8786
88- // Transform batch for external storage descriptor fields before writing.
89- if (external_storage_writer_) {
90- auto data_type = arrow::struct_ (write_schema_->fields ());
91- PAIMON_ASSIGN_OR_RAISE_FROM_ARROW (std::shared_ptr<arrow::Array> arrow_array,
92- arrow::ImportArray (batch->GetData (), data_type));
93- auto struct_array = std::dynamic_pointer_cast<arrow::StructArray>(arrow_array);
94- PAIMON_ASSIGN_OR_RAISE (std::shared_ptr<arrow::Array> transformed,
95- external_storage_writer_->TransformBatch (struct_array));
96- auto transformed_struct = std::dynamic_pointer_cast<arrow::StructArray>(transformed);
97- PAIMON_RETURN_NOT_OK (BlobUtils::ValidateBlobInlineFields (
98- transformed_struct, inline_descriptor_fields_, " blob-descriptor-field" ));
99- ::ArrowArray c_transformed;
100- PAIMON_RETURN_NOT_OK_FROM_ARROW (arrow::ExportArray (*transformed, &c_transformed));
101- return writer_->Write (&c_transformed);
102- }
103-
10487 if (!inline_descriptor_fields_.empty () || !inline_view_fields_.empty ()) {
10588 auto data_type = arrow::struct_ (write_schema_->fields ());
10689 PAIMON_ASSIGN_OR_RAISE_FROM_ARROW (std::shared_ptr<arrow::Array> arrow_array,
@@ -188,47 +171,24 @@ Status AppendOnlyWriter::Flush(bool wait_for_latest_compaction, bool forced_full
188171
189172AppendOnlyWriter::RollingFileWriterResult AppendOnlyWriter::CreateRollingRowWriter () {
190173 auto blob_context = BlobFileContext::Create (write_schema_, options_);
191- std::optional<std::vector<std::string>> main_write_cols = write_cols_;
192174
193175 // Save inline descriptor and view fields for validation in Write()
194176 if (blob_context) {
195177 inline_descriptor_fields_ = blob_context->GetDescriptorFields ();
196178 inline_view_fields_ = blob_context->GetViewFields ();
197179 }
198180
199- // Initialize ExternalStorageBlobWriter if needed
200- if (blob_context && blob_context->RequireExternalStorageWriter ()) {
201- assert (blob_context->GetExternalStoragePath ());
202- external_storage_writer_ = std::make_unique<ExternalStorageBlobWriter>(
203- write_schema_, blob_context->GetExternalStorageFields (),
204- blob_context->GetExternalStoragePath ().value (), schema_id_, seq_num_counter_,
205- path_factory_, options_, memory_pool_);
206- if (!main_write_cols) {
207- // To align with java, when require external storage writer, main writer will set write
208- // cols in DataFileMeta
209- main_write_cols = write_schema_->field_names ();
210- }
211- }
212-
213181 if (blob_context && blob_context->RequireBlobFileWriter ()) {
214182 // Use context-aware schema separation: inline BLOB fields stay in main
215183 auto schemas =
216184 BlobUtils::SeparateBlobSchema (write_schema_, blob_context->GetInlineFields ());
217185 return CreateRollingBlobWriter (schemas, blob_context->GetInlineFields ());
218186 }
219187
220- if (!blob_context) {
221- // No BLOB fields at all -> plain rolling writer
222- return std::make_unique<RollingFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>(
223- options_.GetTargetFileSize (/* has_primary_key=*/ false ),
224- GetDataFileWriterFactory (write_schema_, main_write_cols));
225- } else {
226- // All BLOB fields are inline, no .blob files needed -> plain rolling writer
227- // The main data file contains all fields including inline descriptors/views.
228- return std::make_unique<RollingFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>(
229- options_.GetTargetFileSize (/* has_primary_key=*/ false ),
230- GetDataFileWriterFactory (write_schema_, main_write_cols));
231- }
188+ // No BLOB fields, or all BLOB fields are inline and no .blob files are needed.
189+ return std::make_unique<RollingFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>(
190+ options_.GetTargetFileSize (/* has_primary_key=*/ false ),
191+ GetDataFileWriterFactory (write_schema_, write_cols_));
232192}
233193
234194AppendOnlyWriter::WriterFactory AppendOnlyWriter::GetDataFileWriterFactory (
@@ -248,10 +208,9 @@ AppendOnlyWriter::WriterFactory AppendOnlyWriter::GetBlobFileWriterFactory(
248208 const std::shared_ptr<arrow::Schema>& single_field_schema,
249209 const std::optional<std::vector<std::string>>& write_cols) const {
250210 std::shared_ptr<DataFilePathFactory> path_factory = path_factory_;
251- return std::make_shared<BlobDataFileWriterFactory>(
252- options_, schema_id_, single_field_schema, write_cols, seq_num_counter_, path_factory,
253- [path_factory]() { return path_factory->NewBlobPath (); },
254- blob::BlobFormatWriter::WriteConsumer (), memory_pool_);
211+ return std::make_shared<BlobDataFileWriterFactory>(options_, schema_id_, single_field_schema,
212+ write_cols, seq_num_counter_, path_factory,
213+ memory_pool_);
255214}
256215
257216AppendOnlyWriter::RollingFileWriterResult AppendOnlyWriter::CreateRollingBlobWriter (
@@ -306,11 +265,6 @@ Status AppendOnlyWriter::Close() {
306265 writer_.reset ();
307266 }
308267
309- if (external_storage_writer_) {
310- PAIMON_RETURN_NOT_OK (external_storage_writer_->Close ());
311- external_storage_writer_.reset ();
312- }
313-
314268 if (compact_deletion_file_ != nullptr ) {
315269 compact_deletion_file_->Clean ();
316270 }
0 commit comments