@@ -46,7 +46,8 @@ namespace doris {
4646
4747using strings::Substitute;
4848
49- Status convert_to_arrow_type (const TypeDescriptor& type, std::shared_ptr<arrow::DataType>* result) {
49+ Status convert_to_arrow_type (const TypeDescriptor& type, std::shared_ptr<arrow::DataType>* result,
50+ const std::string& timezone) {
5051 switch (type.type ) {
5152 case TYPE_NULL :
5253 *result = arrow::null ();
@@ -96,11 +97,11 @@ Status convert_to_arrow_type(const TypeDescriptor& type, std::shared_ptr<arrow::
9697 break ;
9798 case TYPE_DATETIMEV2 :
9899 if (type.scale > 3 ) {
99- *result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MICRO );
100+ *result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MICRO , timezone );
100101 } else if (type.scale > 0 ) {
101- *result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MILLI );
102+ *result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MILLI , timezone );
102103 } else {
103- *result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::SECOND );
104+ *result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::SECOND , timezone );
104105 }
105106 break ;
106107 case TYPE_DECIMALV2 :
@@ -120,16 +121,16 @@ Status convert_to_arrow_type(const TypeDescriptor& type, std::shared_ptr<arrow::
120121 case TYPE_ARRAY : {
121122 DCHECK_EQ (type.children .size (), 1 );
122123 std::shared_ptr<arrow::DataType> item_type;
123- static_cast <void >(convert_to_arrow_type (type.children [0 ], &item_type));
124+ static_cast <void >(convert_to_arrow_type (type.children [0 ], &item_type, timezone ));
124125 *result = std::make_shared<arrow::ListType>(item_type);
125126 break ;
126127 }
127128 case TYPE_MAP : {
128129 DCHECK_EQ (type.children .size (), 2 );
129130 std::shared_ptr<arrow::DataType> key_type;
130131 std::shared_ptr<arrow::DataType> val_type;
131- static_cast <void >(convert_to_arrow_type (type.children [0 ], &key_type));
132- static_cast <void >(convert_to_arrow_type (type.children [1 ], &val_type));
132+ static_cast <void >(convert_to_arrow_type (type.children [0 ], &key_type, timezone ));
133+ static_cast <void >(convert_to_arrow_type (type.children [1 ], &val_type, timezone ));
133134 *result = std::make_shared<arrow::MapType>(key_type, val_type);
134135 break ;
135136 }
@@ -138,7 +139,7 @@ Status convert_to_arrow_type(const TypeDescriptor& type, std::shared_ptr<arrow::
138139 std::vector<std::shared_ptr<arrow::Field>> fields;
139140 for (size_t i = 0 ; i < type.children .size (); i++) {
140141 std::shared_ptr<arrow::DataType> field_type;
141- static_cast <void >(convert_to_arrow_type (type.children [i], &field_type));
142+ static_cast <void >(convert_to_arrow_type (type.children [i], &field_type, timezone ));
142143 fields.push_back (std::make_shared<arrow::Field>(type.field_names [i], field_type,
143144 type.contains_nulls [i]));
144145 }
@@ -156,19 +157,21 @@ Status convert_to_arrow_type(const TypeDescriptor& type, std::shared_ptr<arrow::
156157 return Status::OK ();
157158}
158159
159- Status convert_to_arrow_field (SlotDescriptor* desc, std::shared_ptr<arrow::Field>* field) {
160+ Status convert_to_arrow_field (SlotDescriptor* desc, std::shared_ptr<arrow::Field>* field,
161+ const std::string& timezone) {
160162 std::shared_ptr<arrow::DataType> type;
161- RETURN_IF_ERROR (convert_to_arrow_type (desc->type (), &type));
163+ RETURN_IF_ERROR (convert_to_arrow_type (desc->type (), &type, timezone ));
162164 *field = arrow::field (desc->col_name (), type, desc->is_nullable ());
163165 return Status::OK ();
164166}
165167
166- Status get_arrow_schema (const vectorized::Block& block, std::shared_ptr<arrow::Schema>* result) {
168+ Status get_arrow_schema (const vectorized::Block& block, std::shared_ptr<arrow::Schema>* result,
169+ const std::string& timezone) {
167170 std::vector<std::shared_ptr<arrow::Field>> fields;
168171 for (const auto & type_and_name : block) {
169172 std::shared_ptr<arrow::DataType> arrow_type;
170173 RETURN_IF_ERROR (convert_to_arrow_type (type_and_name.type ->get_type_as_type_descriptor (),
171- &arrow_type));
174+ &arrow_type, timezone ));
172175 fields.push_back (std::make_shared<arrow::Field>(type_and_name.name , arrow_type,
173176 type_and_name.type ->is_nullable ()));
174177 }
@@ -177,12 +180,13 @@ Status get_arrow_schema(const vectorized::Block& block, std::shared_ptr<arrow::S
177180}
178181
179182Status convert_expr_ctxs_arrow_schema (const vectorized::VExprContextSPtrs& output_vexpr_ctxs,
180- std::shared_ptr<arrow::Schema>* result) {
183+ std::shared_ptr<arrow::Schema>* result,
184+ const std::string& timezone) {
181185 std::vector<std::shared_ptr<arrow::Field>> fields;
182186 for (int i = 0 ; i < output_vexpr_ctxs.size (); i++) {
183187 std::shared_ptr<arrow::DataType> arrow_type;
184188 auto root_expr = output_vexpr_ctxs.at (i)->root ();
185- RETURN_IF_ERROR (convert_to_arrow_type (root_expr->type (), &arrow_type));
189+ RETURN_IF_ERROR (convert_to_arrow_type (root_expr->type (), &arrow_type, timezone ));
186190 auto field_name = root_expr->is_slot_ref () && !root_expr->expr_label ().empty ()
187191 ? root_expr->expr_label ()
188192 : fmt::format (" {}_{}" , root_expr->data_type ()->get_name (), i);
0 commit comments