Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion be/src/core/data_type/data_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ ColumnPtr IDataType::create_column_const(size_t size, const Field& field) const
}

ColumnPtr IDataType::create_column_const_with_default_value(size_t size) const {
return create_column_const(size, get_default());
auto column = create_column();
column->insert_default();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper is no longer equivalent to the removed get_default() for complex types. For Array, Map, and JSONB, insert_default() yields [], {}, and SQL NULL instead of the previous synthetic defaults ([null], {null:null}, JSON null), and the regression diff in test_partial_update_complex_type.out already shows that behavior change. Because this helper is shared by many non-storage call sites, the PR is not behavior-preserving anymore.

return ColumnConst::create(std::move(column), size);
}

size_t IDataType::get_size_of_value_in_memory() const {
Expand Down
5 changes: 0 additions & 5 deletions be/src/core/data_type/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ class IDataType : private boost::noncopyable {
ColumnPtr create_column_const(size_t size, const Field& field) const;
ColumnPtr create_column_const_with_default_value(size_t size) const;

/** Get default value of data type.
* It is the "default" default, regardless the fact that a table could contain different user-specified default.
*/
virtual Field get_default() const = 0;

virtual Field get_field(const TExprNode& node) const = 0;

/// Checks that two instances belong to the same type
Expand Down
6 changes: 0 additions & 6 deletions be/src/core/data_type/data_type_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ Status DataTypeArray::check_column(const IColumn& column) const {
return nested->check_column(column_array->get_data());
}

Field DataTypeArray::get_default() const {
Array a;
a.push_back(nested->get_default());
return Field::create_field<TYPE_ARRAY>(a);
}

bool DataTypeArray::equals(const IDataType& rhs) const {
return typeid(rhs) == typeid(*this) &&
nested->equals(*static_cast<const DataTypeArray&>(rhs).nested);
Expand Down
1 change: 0 additions & 1 deletion be/src/core/data_type/data_type_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class DataTypeArray final : public IDataType {

MutableColumnPtr create_column() const override;
Status check_column(const IColumn& column) const override;
Field get_default() const override;

[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
Expand Down
4 changes: 0 additions & 4 deletions be/src/core/data_type/data_type_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class DataTypeBitMap : public IDataType {

bool equals(const IDataType& rhs) const override { return typeid(rhs) == typeid(*this); }

Field get_default() const override {
return Field::create_field<TYPE_BITMAP>(BitmapValue::empty_bitmap());
}

[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Unimplemented get_field for BitMap");
Expand Down
5 changes: 0 additions & 5 deletions be/src/core/data_type/data_type_decimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ void DataTypeDecimal<T>::to_pb_column_meta(PColumnMeta* col_meta) const {
}
}

template <PrimitiveType T>
Field DataTypeDecimal<T>::get_default() const {
return Field::create_field<T>(typename PrimitiveTypeTraits<T>::CppType());
}

template <PrimitiveType T>
MutableColumnPtr DataTypeDecimal<T>::create_column() const {
return ColumnType::create(0, scale);
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ class DataTypeDecimal final : public IDataType, public DecimalScaleInfo<T> {
int be_exec_version) const override;
void to_pb_column_meta(PColumnMeta* col_meta) const override;

Field get_default() const override;

Field get_field(const TExprNode& node) const override {
DCHECK_EQ(node.node_type, TExprNodeType::DECIMAL_LITERAL);
DCHECK(node.__isset.decimal_literal);
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_fixed_length_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class DataTypeFixedLengthObject final : public IDataType {
return doris::FieldType::OLAP_FIELD_TYPE_NONE;
}

Field get_default() const override { return Field::create_field<TYPE_STRING>(String()); }

[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Unimplemented get_field for DataTypeFixedLengthObject");
Expand Down
4 changes: 0 additions & 4 deletions be/src/core/data_type/data_type_hll.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class DataTypeHLL : public IDataType {

bool equals(const IDataType& rhs) const override { return typeid(rhs) == typeid(*this); }

Field get_default() const override {
return Field::create_field<TYPE_HLL>(HyperLogLog::empty());
}

[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "Unimplemented get_field for HLL");
}
Expand Down
11 changes: 0 additions & 11 deletions be/src/core/data_type/data_type_jsonb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ class IColumn;
} // namespace doris

namespace doris {
Field DataTypeJsonb::get_default() const {
std::string default_json = "null";
// convert default_json to binary
JsonBinaryValue jsonb_value;
THROW_IF_ERROR(jsonb_value.from_json_string(default_json));
// Throw exception if default_json.size() is large than INT32_MAX
// JsonbField keeps its own memory
return Field::create_field<TYPE_JSONB>(
JsonbField(jsonb_value.value(), cast_set<Int32>(jsonb_value.size())));
}

Field DataTypeJsonb::get_field(const TExprNode& node) const {
DCHECK_EQ(node.node_type, TExprNodeType::JSON_LITERAL);
DCHECK(node.__isset.json_literal);
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_jsonb.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ class DataTypeJsonb final : public IDataType {
MutableColumnPtr create_column() const override;
Status check_column(const IColumn& column) const override;

Field get_default() const override;

Field get_field(const TExprNode& node) const override;

FieldWithDataType get_field_with_data_type(const IColumn& column,
Expand Down
10 changes: 0 additions & 10 deletions be/src/core/data_type/data_type_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ DataTypeMap::DataTypeMap(const DataTypePtr& key_type_, const DataTypePtr& value_
value_type = value_type_;
}

Field DataTypeMap::get_default() const {
Map m;
Array key, val;
key.push_back(key_type->get_default());
val.push_back(value_type->get_default());
m.push_back(Field::create_field<TYPE_ARRAY>(key));
m.push_back(Field::create_field<TYPE_ARRAY>(val));
return Field::create_field<TYPE_MAP>(m);
};

MutableColumnPtr DataTypeMap::create_column() const {
return ColumnMap::create(key_type->create_column(), value_type->create_column(),
ColumnArray::ColumnOffsets::create());
Expand Down
1 change: 0 additions & 1 deletion be/src/core/data_type/data_type_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class DataTypeMap final : public IDataType {

MutableColumnPtr create_column() const override;
Status check_column(const IColumn& column) const override;
Field get_default() const override;

[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "Unimplemented get_field for map");
Expand Down
6 changes: 0 additions & 6 deletions be/src/core/data_type/data_type_nothing.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ class DataTypeNothing final : public IDataType {
const char* deserialize(const char* buf, MutableColumnPtr* column,
int be_exec_version) const override;

[[noreturn]] Field get_default() const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Method get_default() is not implemented for data type {}.",
get_name());
}

[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Unimplemented get_field for Nothing");
Expand Down
4 changes: 0 additions & 4 deletions be/src/core/data_type/data_type_nullable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ Status DataTypeNullable::check_column(const IColumn& column) const {
return nested_data_type->check_column(column_nullable->get_nested_column());
}

Field DataTypeNullable::get_default() const {
return Field();
}

bool DataTypeNullable::equals(const IDataType& rhs) const {
return rhs.is_nullable() &&
nested_data_type->equals(*static_cast<const DataTypeNullable&>(rhs).nested_data_type);
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class DataTypeNullable final : public IDataType {
MutableColumnPtr create_column() const override;
Status check_column(const IColumn& column) const override;

Field get_default() const override;

Field get_field(const TExprNode& node) const override {
if (node.node_type == TExprNodeType::NULL_LITERAL) {
return Field();
Expand Down
5 changes: 0 additions & 5 deletions be/src/core/data_type/data_type_number_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ std::string DataTypeNumberBase<T>::to_string(
}
#endif

template <PrimitiveType T>
Field DataTypeNumberBase<T>::get_default() const {
return Field::create_field<T>(typename PrimitiveTypeTraits<T>::CppType());
}

template <PrimitiveType T>
Field DataTypeNumberBase<T>::get_field(const TExprNode& node) const {
if constexpr (T == TYPE_BOOLEAN) {
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_number_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class DataTypeNumberBase : public IDataType {
throw Exception(Status::FatalError("__builtin_unreachable"));
}

Field get_default() const override;

Field get_field(const TExprNode& node) const override;

int64_t get_uncompressed_serialized_bytes(const IColumn& column,
Expand Down
4 changes: 0 additions & 4 deletions be/src/core/data_type/data_type_quantilestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ class DataTypeQuantileState : public IDataType {

bool equals(const IDataType& rhs) const override { return typeid(rhs) == typeid(*this); }

Field get_default() const override {
return Field::create_field<TYPE_QUANTILE_STATE>(QuantileState());
}

[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Unimplemented get_field for quantile state");
Expand Down
4 changes: 0 additions & 4 deletions be/src/core/data_type/data_type_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@

namespace doris {

Field DataTypeString::get_default() const {
return Field::create_field<TYPE_STRING>(String());
}

MutableColumnPtr DataTypeString::create_column() const {
return ColumnString::create();
}
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ class DataTypeString : public IDataType {
MutableColumnPtr create_column() const override;
Status check_column(const IColumn& column) const override;

Field get_default() const override;

Field get_field(const TExprNode& node) const override {
DCHECK_EQ(node.node_type, TExprNodeType::STRING_LITERAL);
DCHECK(node.__isset.string_literal);
Expand Down
9 changes: 0 additions & 9 deletions be/src/core/data_type/data_type_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ Status DataTypeStruct::check_column(const IColumn& column) const {
return Status::OK();
}

Field DataTypeStruct::get_default() const {
size_t size = elems.size();
Tuple t;
for (size_t i = 0; i < size; ++i) {
t.push_back(elems[i]->get_default());
}
return Field::create_field<TYPE_STRUCT>(t);
}

bool DataTypeStruct::equals(const IDataType& rhs) const {
if (typeid(rhs) != typeid(*this)) {
return false;
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ class DataTypeStruct final : public IDataType {
MutableColumnPtr create_column() const override;
Status check_column(const IColumn& column) const override;

Field get_default() const override;

Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Unimplemented get_field for struct");
Expand Down
4 changes: 0 additions & 4 deletions be/src/core/data_type/data_type_varbinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@

namespace doris {

Field DataTypeVarbinary::get_default() const {
return Field::create_field<TYPE_VARBINARY>(StringView());
}

MutableColumnPtr DataTypeVarbinary::create_column() const {
return ColumnVarbinary::create();
}
Expand Down
2 changes: 0 additions & 2 deletions be/src/core/data_type/data_type_varbinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class DataTypeVarbinary : public IDataType {
MutableColumnPtr create_column() const override;
Status check_column(const IColumn& column) const override;

Field get_default() const override;

Field get_field(const TExprNode& node) const override {
DCHECK_EQ(node.node_type, TExprNodeType::VARBINARY_LITERAL);
DCHECK(node.__isset.varbinary_literal);
Expand Down
1 change: 0 additions & 1 deletion be/src/core/data_type/data_type_variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class DataTypeVariant : public IDataType {
char* serialize(const IColumn& column, char* buf, int be_exec_version) const override;
const char* deserialize(const char* buf, MutableColumnPtr* column,
int be_exec_version) const override;
Field get_default() const override { return Field::create_field<TYPE_VARIANT>(VariantMap()); }

Field get_field(const TExprNode& node) const override;

Expand Down
6 changes: 3 additions & 3 deletions be/src/storage/partial_update_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ Status FixedReadPlan::fill_missing_columns(
// If the control flow reaches this branch, the column neither has default value
// nor is nullable. It means that the row's delete sign is marked, and the value
// columns are useless and won't be read. So we can just put arbitary values in the cells
missing_col->insert(tablet_column.get_vec_type()->get_default());
missing_col->insert_default();
}
} else {
missing_col->insert_from(*old_value_block.get_by_position(i).column,
Expand Down Expand Up @@ -618,7 +618,7 @@ static void fill_non_primary_key_cell_for_column_store(
// store the generated auto-increment value in fixed partial update
new_col->insert_from(cur_col, block_pos);
} else {
new_col->insert(tablet_column.get_vec_type()->get_default());
new_col->insert_default();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same issue exists in flexible partial update. _probe_key_for_mow() sends insert-after-delete rows down the use_default path without calling handle_new_key(), so these values become the visible contents of the re-inserted row. With this change, skipped non-null complex columns now persist [], {}, and SQL NULL instead of the previous synthetic defaults.

}
} else {
auto pos_in_old_block = read_index.at(cid).at(segment_pos);
Expand Down Expand Up @@ -724,7 +724,7 @@ static void fill_non_primary_key_cell_for_row_store(
// store the generated auto-increment value in fixed partial update
new_col->insert_from(cur_col, block_pos);
} else {
new_col->insert(tablet_column.get_vec_type()->get_default());
new_col->insert_default();
Comment thread
Mryange marked this conversation as resolved.
}
} else {
new_col->insert_from(old_value_col, pos_in_old_block);
Expand Down
4 changes: 2 additions & 2 deletions be/src/storage/tablet/base_tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ Status BaseTablet::generate_new_block_for_partial_update(
mutable_column.get())
->insert_default();
} else {
mutable_column->insert(rs_column.get_vec_type()->get_default());
mutable_column->insert_default();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is not just filling dead payload. When a fixed partial update hits a previously delete-marked row, use_default becomes true and the new row is rebuilt from these values. Replacing get_default() with insert_default() therefore changes committed results for non-null complex columns from the previous synthetic defaults to [], {}, and SQL NULL.

}
} else {
mutable_column->insert_from(*old_block.get_by_position(i).column,
Expand Down Expand Up @@ -1125,7 +1125,7 @@ static void fill_cell_for_flexible_partial_update(
// keep consistency between replicas
new_col->insert_from(cur_col, read_index_update[cast_set<uint32_t>(idx)]);
} else {
new_col->insert(tablet_column.get_vec_type()->get_default());
new_col->insert_default();
Comment thread
Mryange marked this conversation as resolved.
}
} else {
new_col->insert_from(old_value_col, read_index_old[cast_set<uint32_t>(idx)]);
Expand Down
5 changes: 4 additions & 1 deletion be/test/core/column/column_variant_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,10 @@ TEST_F(ColumnVariantTest, clone_resized) {
for (; i < clone_count; ++i) {
// more than source size
Field target_field;
Field source_field = column_variant->get_root_type()->get_default();
auto default_column = column_variant->get_root_type()->create_column();
default_column->insert_default();
Field source_field;
default_column->get(0, source_field);
target_column->get(i, target_field);
EXPECT_EQ(target_field, source_field)
<< "target_field: " << target_field.get_type_name()
Expand Down
1 change: 0 additions & 1 deletion be/test/core/data_type/common_data_type_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class CommonDataTypeTest : public ::testing::Test {
EXPECT_EQ(data_type->get_scale(), 0);
}
ASSERT_EQ(data_type->is_null_literal(), meta_info.is_null_literal);
ASSERT_EQ(data_type->get_default(), meta_info.default_field);
}

// create column assert with default field is simple and can be used for all DataType
Expand Down
6 changes: 1 addition & 5 deletions be/test/core/data_type/data_type_array_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,10 @@ class DataTypeArrayTest : public CommonDataTypeTest {
TEST_F(DataTypeArrayTest, MetaInfoTest) {
for (auto& type : array_types) {
const auto* array_type = assert_cast<const DataTypeArray*>(remove_nullable(type).get());
auto nested_type =
assert_cast<const DataTypeArray*>(remove_nullable(type).get())->get_nested_type();

auto arr_type_descriptor = type;
auto col_meta = std::make_shared<PColumnMeta>();
array_type->to_pb_column_meta(col_meta.get());
Array a;
a.push_back(nested_type->get_default());

DataTypeMetaInfo arr_meta_info_to_assert = {
.type_id = PrimitiveType::TYPE_ARRAY,
Expand All @@ -354,7 +350,7 @@ TEST_F(DataTypeArrayTest, MetaInfoTest) {
.scale = size_t(-1),
.is_null_literal = false,
.pColumnMeta = col_meta.get(),
.default_field = Field::create_field<TYPE_ARRAY>(a),
.default_field = Field::create_field<TYPE_ARRAY>(Array()),
};
DataTypePtr arr = remove_nullable(type);
meta_info_assert(arr, arr_meta_info_to_assert);
Expand Down
17 changes: 0 additions & 17 deletions be/test/core/data_type/data_type_datetime_v2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,6 @@ TEST_F(DataTypeDateTimeV2Test, simple_func_test) {
EXPECT_THROW(DataTypeTimeV2(7), Exception);
}

TEST_F(DataTypeDateTimeV2Test, get_default) {
auto v = 0UL;
EXPECT_EQ(dt_datetime_v2_0.get_default(),
Field::create_field<TYPE_DATETIMEV2>(
*(typename PrimitiveTypeTraits<TYPE_DATETIMEV2>::CppType*)&v));
EXPECT_EQ(dt_datetime_v2_5.get_default(),
Field::create_field<TYPE_DATETIMEV2>(
*(typename PrimitiveTypeTraits<TYPE_DATETIMEV2>::CppType*)&v));
EXPECT_EQ(dt_datetime_v2_6.get_default(),
Field::create_field<TYPE_DATETIMEV2>(
*(typename PrimitiveTypeTraits<TYPE_DATETIMEV2>::CppType*)&v));
EXPECT_EQ(dt_date_v2.get_default(),
Field::create_field<TYPE_DATEV2>(
*(typename PrimitiveTypeTraits<TYPE_DATEV2>::CppType*)&v));
EXPECT_EQ(dt_time_v2_6.get_default(), Field::create_field<TYPE_TIMEV2>(0.0));
}

TEST_F(DataTypeDateTimeV2Test, get_field) {
config::allow_zero_date = true;
{
Expand Down
Loading
Loading