yiguolei commented on code in PR #66204:
URL: https://github.com/apache/doris/pull/66204#discussion_r3728338891
##########
be/src/core/column/variant_v2/column_variant_v2.cpp:
##########
@@ -651,16 +664,62 @@ VariantRef ColumnVariantV2::get_value_ref(size_t row)
const {
return {.metadata = {.data = metadata.data, .size = metadata.size}, .value
= value};
}
-Field ColumnVariantV2::operator[](size_t) const {
- throw_deferred("operator[]", "T1.7b Field rebind");
+Field ColumnVariantV2::operator[](size_t row) const {
+ Field result;
+ get(row, result);
+ return result;
}
-void ColumnVariantV2::get(size_t, Field&) const {
- throw_deferred("get", "T1.7b Field rebind");
-}
+void ColumnVariantV2::get(size_t row, Field& result) const {
+ if (UNLIKELY(row >= size())) {
+ throw Exception(ErrorCode::OUT_OF_BOUND,
+ "Index ({}) for getting Variant field is out of range
for size {}", row,
+ size());
+ }
-void ColumnVariantV2::insert(const Field&) {
- throw_deferred("insert(Field)", "T1.7b Field rebind");
+ VariantField value;
+ if (_typed) {
+ const auto& nullable = assert_cast<const ColumnNullable&>(*_typed);
+ visit_typed_scalar_column(
+ nullable, _typed_type->get_primitive_type(),
_typed_type->get_scale(), row, row + 1,
+ [&](size_t, const VariantScalarRef& scalar) { value =
field_from_scalar(scalar); });
+ } else {
+ value = VariantField::from_ref(get_value_ref(row));
+ }
+ result = Field::create_field<TYPE_VARIANT>(std::move(value));
+}
+
+void ColumnVariantV2::insert(const Field& field) {
+ VariantField null_value;
+ const VariantField* value = nullptr;
+ if (field.get_type() == TYPE_NULL) {
+ null_value = field_from_scalar(VariantScalarRef::null_value());
+ value = &null_value;
+ } else if (field.get_type() == TYPE_VARIANT) {
+ value = &field.get<TYPE_VARIANT>();
Review Comment:
为啥这么写?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]