2929#include " core/block/block.h"
3030#include " core/block/column_with_type_and_name.h"
3131#include " format/table/paimon_doris_file_system.h"
32+ #include " format/table/partition_column_filler.h"
3233#include " paimon/defs.h"
3334#include " paimon/memory/memory_pool.h"
3435#include " paimon/read_context.h"
@@ -73,6 +74,12 @@ Status PaimonCppReader::on_before_init_reader(ReaderInitContext* ctx) {
7374 return Status::OK ();
7475 }
7576
77+ DORIS_CHECK (ctx->range ->__isset .columns_from_path );
78+ DORIS_CHECK (ctx->range ->__isset .columns_from_path_is_null );
79+ DORIS_CHECK (ctx->range ->columns_from_path .size () == ctx->range ->columns_from_path_keys .size ());
80+ DORIS_CHECK (ctx->range ->columns_from_path_is_null .size () ==
81+ ctx->range ->columns_from_path_keys .size ());
82+
7683 std::unordered_map<std::string, const SlotDescriptor*> name_to_slot;
7784 for (auto * slot : ctx->tuple_descriptor ->slots ()) {
7885 name_to_slot.emplace (slot->col_name (), slot);
@@ -83,15 +90,9 @@ Status PaimonCppReader::on_before_init_reader(ReaderInitContext* ctx) {
8390 if (slot_it == name_to_slot.end ()) {
8491 continue ;
8592 }
86- std::string value;
87- if (ctx->range ->__isset .columns_from_path && i < ctx->range ->columns_from_path .size ()) {
88- value = ctx->range ->columns_from_path [i];
89- }
90- _partition_values.emplace (key, std::make_tuple (std::move (value), slot_it->second ));
91- if (ctx->range ->__isset .columns_from_path_is_null &&
92- i < ctx->range ->columns_from_path_is_null .size ()) {
93- _partition_value_is_null.emplace (key, ctx->range ->columns_from_path_is_null [i]);
94- }
93+ _partition_values.emplace (
94+ key, std::make_tuple (ctx->range ->columns_from_path [i], slot_it->second ));
95+ _partition_value_is_null.emplace (key, ctx->range ->columns_from_path_is_null [i]);
9596 }
9697 return Status::OK ();
9798}
@@ -198,7 +199,6 @@ Status PaimonCppReader::_fill_partition_columns(Block* block, size_t num_rows) {
198199 _col_name_to_block_idx = block->get_name_to_pos_map ();
199200 }
200201
201- DataTypeSerDe::FormatOptions text_format_options;
202202 for (const auto & desc : *_column_descs) {
203203 if (desc.category != ColumnCategory::PARTITION_KEY ) {
204204 continue ;
@@ -215,34 +215,10 @@ Status PaimonCppReader::_fill_partition_columns(Block* block, size_t num_rows) {
215215
216216 auto mutable_column = block->get_by_position (col_it->second ).column ->assume_mutable ();
217217 const auto & [value, slot_desc] = value_it->second ;
218- auto text_serde = slot_desc->get_data_type_ptr ()->get_serde ();
219- uint64_t num_deserialized = 0 ;
220- bool is_null = _partition_value_is_null.contains (desc.name ) &&
221- _partition_value_is_null.at (desc.name );
222- if (is_null) {
223- DCHECK (slot_desc->get_data_type_ptr ()->is_nullable ());
224- auto * nullable_column = assert_cast<ColumnNullable*>(mutable_column.get ());
225- nullable_column->insert_many_defaults (num_rows);
226- continue ;
227- }
228-
229- Slice slice (value.data (), value.size ());
230- if (slot_desc->get_data_type_ptr ()->is_nullable ()) {
231- auto * nullable_column = assert_cast<ColumnNullable*>(mutable_column.get ());
232- auto nested_serde = text_serde->get_nested_serdes ()[0 ];
233- nullable_column->get_null_map_column ().insert_many_vals (0 , num_rows);
234- RETURN_IF_ERROR (nested_serde->deserialize_column_from_fixed_json (
235- nullable_column->get_nested_column (), slice, num_rows, &num_deserialized,
236- text_format_options));
237- } else {
238- RETURN_IF_ERROR (text_serde->deserialize_column_from_fixed_json (
239- *mutable_column, slice, num_rows, &num_deserialized, text_format_options));
240- }
241- if (num_deserialized != num_rows) {
242- return Status::InternalError (
243- " Failed to fill partition column: {}={}. Expected rows: {}, actual: {}" ,
244- slot_desc->col_name (), value, num_rows, num_deserialized);
245- }
218+ auto null_it = _partition_value_is_null.find (desc.name );
219+ DORIS_CHECK (null_it != _partition_value_is_null.end ());
220+ RETURN_IF_ERROR (fill_partition_column_from_path_value (*mutable_column, *slot_desc, value,
221+ num_rows, null_it->second ));
246222 }
247223 return Status::OK ();
248224}
0 commit comments