@@ -96,11 +96,6 @@ Result<LuminaTagField> ParseTagField(const rapidjson::Value& obj, const std::str
9696 return Status::Invalid (
9797 fmt::format (" lumina tag_schema {} key_name must not be empty" , tag_label));
9898 }
99- if (key_name.size () > ::lumina::core::kMaxTagKNameLength ) {
100- return Status::Invalid (fmt::format (" lumina tag_schema {} key_name exceeds max length {}" ,
101- tag_label, ::lumina::core::kMaxTagKNameLength ));
102- }
103-
10499 LuminaTagField::Type parsed_type;
105100 if (type == std::string (::lumina::core::kExtensionTagTypeEnum )) {
106101 parsed_type = LuminaTagField::Type::ENUM ;
@@ -178,6 +173,15 @@ Status AppendTagValue(const std::shared_ptr<arrow::Array>& array, int64_t index,
178173 return Status::OK ();
179174 }
180175
176+ auto validate_array_type = [&](arrow::Type::type expected_type,
177+ const char * value_type_name) -> Status {
178+ if (array->type_id () != expected_type) {
179+ return Status::Invalid (fmt::format (" lumina {} tag field has unsupported arrow type {}" ,
180+ value_type_name, array->type ()->ToString ()));
181+ }
182+ return Status::OK ();
183+ };
184+
181185 if constexpr (std::is_same_v<ValueType, int32_t >) {
182186 switch (array->type_id ()) {
183187 case arrow::Type::INT8 :
@@ -195,30 +199,16 @@ Status AppendTagValue(const std::shared_ptr<arrow::Array>& array, int64_t index,
195199 array->type ()->ToString ()));
196200 }
197201 } else if constexpr (std::is_same_v<ValueType, int64_t >) {
198- if (array->type_id () != arrow::Type::INT64 ) {
199- return Status::Invalid (fmt::format (
200- " lumina int64 tag field has unsupported arrow type {}" , array->type ()->ToString ()));
201- }
202+ PAIMON_RETURN_NOT_OK (validate_array_type (arrow::Type::INT64 , " int64" ));
202203 AppendPrimitiveTagValue<ValueType, arrow::Int64Array>(array, index, values);
203204 } else if constexpr (std::is_same_v<ValueType, float >) {
204- if (array->type_id () != arrow::Type::FLOAT ) {
205- return Status::Invalid (fmt::format (
206- " lumina float tag field has unsupported arrow type {}" , array->type ()->ToString ()));
207- }
205+ PAIMON_RETURN_NOT_OK (validate_array_type (arrow::Type::FLOAT , " float" ));
208206 AppendPrimitiveTagValue<ValueType, arrow::FloatArray>(array, index, values);
209207 } else if constexpr (std::is_same_v<ValueType, double >) {
210- if (array->type_id () != arrow::Type::DOUBLE ) {
211- return Status::Invalid (
212- fmt::format (" lumina double tag field has unsupported arrow type {}" ,
213- array->type ()->ToString ()));
214- }
208+ PAIMON_RETURN_NOT_OK (validate_array_type (arrow::Type::DOUBLE , " double" ));
215209 AppendPrimitiveTagValue<ValueType, arrow::DoubleArray>(array, index, values);
216210 } else if constexpr (std::is_same_v<ValueType, std::string>) {
217- if (array->type_id () != arrow::Type::STRING ) {
218- return Status::Invalid (
219- fmt::format (" lumina string tag field has unsupported arrow type {}" ,
220- array->type ()->ToString ()));
221- }
211+ PAIMON_RETURN_NOT_OK (validate_array_type (arrow::Type::STRING , " string" ));
222212 auto string_array = static_cast <const arrow::StringArray*>(array.get ());
223213 auto view = string_array->GetView (index);
224214 values->emplace_back (view.data (), view.size ());
0 commit comments