github-actions[bot] commented on code in PR #70223:
URL: https://github.com/apache/doris/pull/70223#discussion_r4663715047
##########
be/test/core/data_type/data_type_agg_state_test.cpp:
##########
@@ -64,15 +65,143 @@ class DataTypeAggStateTest : public
::testing::TestWithParam<int> {
DataTypes sub_types = {sub_type};
// DataTypeAggState---> column_fixed_length_object
DataTypePtr datatype_agg_state_count = std::make_shared<DataTypeAggState>(
- sub_types, false, "count",
BeExecVersionManager::get_newest_version());
+ sub_types, false, "count",
BeExecVersionManager::get_newest_version(),
+ std::make_shared<DataTypeInt64>());
// DataTypeAggState---> column_string
DataTypePtr datatype_agg_state_hll_union =
std::make_shared<DataTypeAggState>(
- sub_types, false, "hll_union",
BeExecVersionManager::get_newest_version());
+ sub_types, false, "hll_union",
BeExecVersionManager::get_newest_version(),
+ DataTypeFactory::instance().create_data_type(TYPE_HLL, false));
int rows_value;
};
+TEST_P(DataTypeAggStateTest, EffectiveResultTypeEquality) {
+ const auto version = BeExecVersionManager::get_newest_version();
+ auto input = std::make_shared<DataTypeInt32>();
+ auto result = std::make_shared<DataTypeInt64>();
+ auto legacy =
+ std::make_shared<DataTypeAggState>(DataTypes {input}, true, "sum",
version, nullptr);
+ auto explicit_type =
+ std::make_shared<DataTypeAggState>(DataTypes {input}, true, "sum",
version, result);
+ EXPECT_TRUE(legacy->equals(*explicit_type));
+ EXPECT_TRUE(explicit_type->equals(*legacy));
+
+ auto different_input =
+ std::make_shared<DataTypeAggState>(DataTypes {result}, true,
"sum", version, result);
+ auto nullable_input = std::make_shared<DataTypeAggState>(
+ DataTypes {DataTypeFactory::instance().create_data_type(TYPE_INT,
true)}, true, "sum",
+ version, result);
+ auto non_nullable_result =
+ std::make_shared<DataTypeAggState>(DataTypes {input}, false,
"sum", version, result);
+ auto different_function =
+ std::make_shared<DataTypeAggState>(DataTypes {input}, true, "max",
version, input);
+ for (const auto& incompatible :
+ {different_input, nullable_input, non_nullable_result,
different_function}) {
+ EXPECT_FALSE(legacy->equals(*incompatible));
+ EXPECT_FALSE(incompatible->equals(*legacy));
+ }
+ PColumnMeta forwarded;
+ legacy->to_pb_column_meta(&forwarded);
+ EXPECT_FALSE(forwarded.has_agg_state_result_type());
+ auto restored = DataTypeFactory::instance().create_data_type(forwarded);
+ EXPECT_TRUE(restored->equals(*explicit_type));
+ EXPECT_TRUE(explicit_type->equals(*restored));
+
+ DataTypeAggState primitive;
+ DataTypeAggState another_primitive;
+ EXPECT_TRUE(primitive.equals(another_primitive));
+ EXPECT_FALSE(primitive.equals(*legacy));
+ EXPECT_FALSE(legacy->equals(primitive));
+ EXPECT_FALSE(legacy->equals(*input));
+}
+
+TEST_P(DataTypeAggStateTest, DecimalAvgResultSignature) {
+ auto input = DataTypeFactory::instance().create_data_type(TYPE_DECIMAL64,
true, 18, 2);
+ auto result =
DataTypeFactory::instance().create_data_type(TYPE_DECIMAL256, false, 76, 4);
+ const auto version = BeExecVersionManager::get_newest_version();
+ auto explicit_type =
+ std::make_shared<DataTypeAggState>(DataTypes {input}, true, "avg",
version, result);
+ auto decimal128 = std::make_shared<DataTypeAggState>(
+ DataTypes {input}, true, "avg", version,
+ DataTypeFactory::instance().create_data_type(TYPE_DECIMAL128I,
false, 38, 4));
+
EXPECT_EQ(explicit_type->get_nested_function()->get_return_type()->get_name(),
+ "Nullable(Decimal(76, 4))");
+ EXPECT_EQ(decimal128->get_nested_function()->get_return_type()->get_name(),
+ "Nullable(Decimal(38, 4))");
+ EXPECT_FALSE(explicit_type->equals(*decimal128));
+ EXPECT_FALSE(decimal128->equals(*explicit_type));
+
+ PColumnMeta metadata;
+ explicit_type->to_pb_column_meta(&metadata);
+ ASSERT_TRUE(metadata.has_agg_state_result_type());
+ auto restored = DataTypeFactory::instance().create_data_type(metadata);
+ EXPECT_TRUE(explicit_type->equals(*restored));
+ ColumnPB column;
+ column.set_unique_id(1);
+ column.set_name("s");
+ column.set_type("AGG_STATE");
+ column.set_aggregation("avg");
+ column.set_result_is_nullable(true);
+ column.set_be_exec_version(version);
+ result->to_protobuf(column.mutable_agg_state_result_type());
+ auto* child = column.add_children_columns();
+ child->set_unique_id(2);
+ child->set_type("DECIMAL64");
+ child->set_precision(18);
+ child->set_frac(2);
+ child->set_is_nullable(true);
+ TabletColumn tablet_column(column);
+ ColumnPB persisted;
+ tablet_column.to_schema_pb(&persisted);
+ ASSERT_TRUE(persisted.has_agg_state_result_type());
+ EXPECT_TRUE(explicit_type->equals(
+
*DataTypeFactory::instance().create_data_type(TabletColumn(persisted))));
+ column.clear_agg_state_result_type();
+ EXPECT_NE(tablet_column, TabletColumn(column));
+
+ metadata.clear_agg_state_result_type();
+ auto legacy_block = DataTypeFactory::instance().create_data_type(metadata);
+ auto legacy_table =
DataTypeFactory::instance().create_data_type(TabletColumn(column));
+ EXPECT_TRUE(legacy_block->equals(*legacy_table));
+ EXPECT_TRUE(legacy_table->equals(*decimal128));
+ EXPECT_TRUE(decimal128->equals(*legacy_table));
+ EXPECT_FALSE(explicit_type->equals(*legacy_table));
+ EXPECT_FALSE(legacy_block->equals(*explicit_type));
+ const auto* legacy = assert_cast<const
DataTypeAggState*>(legacy_table.get());
+ EXPECT_EQ(legacy->get_nested_function()->get_return_type()->get_name(),
+ "Nullable(Decimal(38, 4))");
+ EXPECT_EQ(legacy->get_nested_function()->size_of_data(),
+ decimal128->get_nested_function()->size_of_data());
+ PColumnMeta forwarded;
+ legacy->to_pb_column_meta(&forwarded);
+ EXPECT_FALSE(forwarded.has_agg_state_result_type());
+
EXPECT_TRUE(legacy_table->equals(*DataTypeFactory::instance().create_data_type(forwarded)));
+}
+
+TEST_P(DataTypeAggStateTest, LegacySegmentResultSignature) {
+ segment_v2::ColumnMetaPB column;
+ column.set_type(static_cast<int>(FieldType::OLAP_FIELD_TYPE_AGG_STATE));
+ column.set_function_name("avg");
+ column.set_result_is_nullable(true);
+ column.set_be_exec_version(SUPPORT_AGG_STATE_RESULT_TYPE_VERSION - 1);
Review Comment:
[P1] Replace the undefined aggregate-state version constant
`SUPPORT_AGG_STATE_RESULT_TYPE_VERSION` has no declaration in this checkout
(the execution-version header ends at
`SUPPORT_VARBINARY_SHUFFLE_HASH_VERSION`). Since `be/test/CMakeLists.txt`
includes this file in `doris_be_test`, the new test fails to compile with an
undeclared identifier and prevents the BE unit-test target from building. Use a
supported execution version for this legacy-metadata case after removing the
result-type gate.
--
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]