[fix](be-ut) fix bitmap_ut result wrong && fix schema_change compile error (#8261)

This commit is contained in:
Pxl
2022-03-01 11:11:02 +08:00
committed by GitHub
parent 0fce094080
commit 7d0e36a054
2 changed files with 70 additions and 65 deletions

View File

@ -180,8 +180,8 @@ public:
}
void set_tablet_schema(const std::string& name, const std::string& type,
const std::string& aggregation, uint32_t length, bool is_allow_null,
bool is_key, TabletSchema* tablet_schema) {
const std::string& aggregation, uint32_t length, bool is_allow_null,
bool is_key, TabletSchema* tablet_schema) {
TabletSchemaPB tablet_schema_pb;
ColumnPB* column = tablet_schema_pb.add_column();
column->set_unique_id(0);
@ -204,7 +204,7 @@ public:
int varchar_len = 255) {
TabletSchema src_tablet_schema;
set_tablet_schema("ConvertColumn", type_name, "REPLACE", type_size, false, false,
&src_tablet_schema);
&src_tablet_schema);
create_column_writer(src_tablet_schema);
RowCursor write_row;
@ -223,7 +223,7 @@ public:
TabletSchema dst_tablet_schema;
set_tablet_schema("VarcharColumn", "VARCHAR", "REPLACE", varchar_len, false, false,
&dst_tablet_schema);
&dst_tablet_schema);
create_column_reader(src_tablet_schema);
RowCursor read_row;
read_row.init(dst_tablet_schema);
@ -267,7 +267,7 @@ public:
TabletSchema converted_tablet_schema;
set_tablet_schema("ConvertColumn", type_name, "REPLACE", type_size, false, false,
&converted_tablet_schema);
&converted_tablet_schema);
create_column_reader(tablet_schema);
RowCursor read_row;
read_row.init(converted_tablet_schema);
@ -355,7 +355,7 @@ TEST_F(TestColumn, ConvertFloatToDouble) {
sprintf(buf, "%f", val2);
char* tg;
double v2 = strtod(buf, &tg);
ASSERT_TRUE(v2 == 1.234);
ASSERT_EQ(v2, 1.234);
//test not support type
TypeInfo* tp = get_scalar_type_info(OLAP_FIELD_TYPE_HLL);
@ -434,7 +434,7 @@ TEST_F(TestColumn, ConvertDateToDatetime) {
TabletSchema convert_tablet_schema;
set_tablet_schema("DateTimeColumn", "DATETIME", "REPLACE", 8, false, false,
&convert_tablet_schema);
&convert_tablet_schema);
create_column_reader(tablet_schema);
RowCursor read_row;
read_row.init(convert_tablet_schema);
@ -691,47 +691,44 @@ TEST_F(TestColumn, ConvertBigIntToVarchar22) {
TEST_F(TestColumn, ConvertLargeIntToVarchar39) {
std::string str_val("170141183460469231731687303715884105727");
StringParser::ParseResult result;
int128_t int128_val = StringParser::string_to_int<int128_t>(str_val.c_str(),
str_val.length(), &result);
int128_t int128_val =
StringParser::string_to_int<int128_t>(str_val.c_str(), str_val.length(), &result);
DCHECK(result == StringParser::PARSE_SUCCESS);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val,
"", OLAP_ERR_INPUT_PARAMETER_ERROR, 39);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val, "",
OLAP_ERR_INPUT_PARAMETER_ERROR, 39);
}
TEST_F(TestColumn, ConvertLargeIntToVarchar41) {
std::string str_val("170141183460469231731687303715884105727");
StringParser::ParseResult result;
int128_t int128_val = StringParser::string_to_int<int128_t>(str_val.c_str(),
str_val.length(), &result);
int128_t int128_val =
StringParser::string_to_int<int128_t>(str_val.c_str(), str_val.length(), &result);
DCHECK(result == StringParser::PARSE_SUCCESS);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val,
str_val,
OLAP_SUCCESS, 41);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val, str_val, OLAP_SUCCESS, 41);
}
TEST_F(TestColumn, ConvertLargeIntToVarchar40) {
std::string str_val = "-170141183460469231731687303715884105727";
StringParser::ParseResult result;
int128_t int128_val = StringParser::string_to_int<int128_t>(str_val.c_str(),
str_val.length(), &result);
int128_t int128_val =
StringParser::string_to_int<int128_t>(str_val.c_str(), str_val.length(), &result);
DCHECK(result == StringParser::PARSE_SUCCESS);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val,
"", OLAP_ERR_INPUT_PARAMETER_ERROR, 40);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val, "",
OLAP_ERR_INPUT_PARAMETER_ERROR, 40);
}
TEST_F(TestColumn, ConvertLargeIntToVarchar46) {
std::string str_val = "-170141183460469231731687303715884105727";
StringParser::ParseResult result;
int128_t int128_val = StringParser::string_to_int<int128_t>(str_val.c_str(),
str_val.length(), &result);
int128_t int128_val =
StringParser::string_to_int<int128_t>(str_val.c_str(), str_val.length(), &result);
DCHECK(result == StringParser::PARSE_SUCCESS);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val,
str_val,
OLAP_SUCCESS, 42);
test_convert_to_varchar<int128_t>("LARGEINT", 16, int128_val, str_val, OLAP_SUCCESS, 42);
}
TEST_F(TestColumn, ConvertFloatToVarchar11) {
test_convert_to_varchar<float>("FLOAT", 4, 3.40282e+38, "3.40282e+38", OLAP_ERR_INPUT_PARAMETER_ERROR, 11);
test_convert_to_varchar<float>("FLOAT", 4, 3.40282e+38, "3.40282e+38",
OLAP_ERR_INPUT_PARAMETER_ERROR, 11);
}
TEST_F(TestColumn, ConvertFloatToVarchar13) {
@ -739,11 +736,13 @@ TEST_F(TestColumn, ConvertFloatToVarchar13) {
}
TEST_F(TestColumn, ConvertFloatToVarchar13_2) {
test_convert_to_varchar<float>("FLOAT", 4, 3402820000000000000l, "3.40282e+18", OLAP_SUCCESS, 13);
test_convert_to_varchar<float>("FLOAT", 4, 3402820000000000000.0, "3.40282e+18", OLAP_SUCCESS,
13);
}
TEST_F(TestColumn, ConvertFloatToVarchar12) {
test_convert_to_varchar<float>("FLOAT", 4, -3.40282e+38, "-3.40282e+38", OLAP_ERR_INPUT_PARAMETER_ERROR, 12);
test_convert_to_varchar<float>("FLOAT", 4, -3.40282e+38, "-3.40282e+38",
OLAP_ERR_INPUT_PARAMETER_ERROR, 12);
}
TEST_F(TestColumn, ConvertFloatToVarchar14) {
@ -751,7 +750,8 @@ TEST_F(TestColumn, ConvertFloatToVarchar14) {
}
TEST_F(TestColumn, ConvertFloatToVarchar14_2) {
test_convert_to_varchar<float>("FLOAT", 4, -3402820000000000000l, "-3.40282e+18", OLAP_SUCCESS, 14);
test_convert_to_varchar<float>("FLOAT", 4, -3402820000000000000.0, "-3.40282e+18", OLAP_SUCCESS,
14);
}
TEST_F(TestColumn, ConvertFloatToVarchar13_3) {
@ -765,7 +765,6 @@ TEST_F(TestColumn, ConvertFloatToVarchar15) {
}
TEST_F(TestColumn, ConvertFloatToVarchar14_3) {
test_convert_to_varchar<float>("FLOAT", 4, -1.17549435082228750796873653722224568e-38F,
"-1.1754944e-38", OLAP_ERR_INPUT_PARAMETER_ERROR, 14);
}
@ -776,7 +775,8 @@ TEST_F(TestColumn, ConvertFloatToVarchar16) {
}
TEST_F(TestColumn, ConvertDoubleToVarchar7) {
test_convert_to_varchar<double>("DOUBLE", 8, 123.456, "123.456", OLAP_ERR_INPUT_PARAMETER_ERROR, 7);
test_convert_to_varchar<double>("DOUBLE", 8, 123.456, "123.456", OLAP_ERR_INPUT_PARAMETER_ERROR,
7);
}
TEST_F(TestColumn, ConvertDoubleToVarchar9) {
@ -794,23 +794,23 @@ TEST_F(TestColumn, ConvertDoubleToVarchar25) {
}
TEST_F(TestColumn, ConvertDoubleToVarchar22) {
test_convert_to_varchar<double>("DOUBLE", 8, 1797693134862315708l,
"1.7976931348623158e+18", OLAP_ERR_INPUT_PARAMETER_ERROR, 22);
test_convert_to_varchar<double>("DOUBLE", 8, 1797693134862315708.0, "1.7976931348623158e+18",
OLAP_ERR_INPUT_PARAMETER_ERROR, 22);
}
TEST_F(TestColumn, ConvertDoubleToVarchar24) {
test_convert_to_varchar<double>("DOUBLE", 8, 1797693134862315708l,
"1.7976931348623158e+18", OLAP_SUCCESS, 24);
test_convert_to_varchar<double>("DOUBLE", 8, 1797693134862315708.0, "1.7976931348623158e+18",
OLAP_SUCCESS, 24);
}
TEST_F(TestColumn, ConvertDoubleToVarchar23_2) {
test_convert_to_varchar<double>("DOUBLE", 8, -1797693134862315708l,
"-1.7976931348623158e+18", OLAP_ERR_INPUT_PARAMETER_ERROR, 23);
test_convert_to_varchar<double>("DOUBLE", 8, -1797693134862315708.0, "-1.7976931348623158e+18",
OLAP_ERR_INPUT_PARAMETER_ERROR, 23);
}
TEST_F(TestColumn, ConvertDoubleToVarchar25_2) {
test_convert_to_varchar<double>("DOUBLE", 8, -1797693134862315708l,
"-1.7976931348623158e+18", OLAP_SUCCESS, 25);
test_convert_to_varchar<double>("DOUBLE", 8, -1797693134862315708.0, "-1.7976931348623158e+18",
OLAP_SUCCESS, 25);
}
TEST_F(TestColumn, ConvertDoubleToVarchar23_3) {
@ -835,8 +835,8 @@ TEST_F(TestColumn, ConvertDoubleToVarchar26) {
TEST_F(TestColumn, ConvertDecimalToVarchar13) {
decimal12_t val = {456, 789000000};
test_convert_to_varchar<decimal12_t>("Decimal", 12, val,
"456.789000000", OLAP_ERR_INPUT_PARAMETER_ERROR, 13);
test_convert_to_varchar<decimal12_t>("Decimal", 12, val, "456.789000000",
OLAP_ERR_INPUT_PARAMETER_ERROR, 13);
}
TEST_F(TestColumn, ConvertDecimalToVarchar15) {
@ -846,24 +846,26 @@ TEST_F(TestColumn, ConvertDecimalToVarchar15) {
TEST_F(TestColumn, ConvertDecimalToVarchar28) {
decimal12_t val = {999999999999999999, 999999999};
test_convert_to_varchar<decimal12_t>("Decimal", 12, val, "", OLAP_ERR_INPUT_PARAMETER_ERROR, 28);
test_convert_to_varchar<decimal12_t>("Decimal", 12, val, "", OLAP_ERR_INPUT_PARAMETER_ERROR,
28);
}
TEST_F(TestColumn, ConvertDecimalToVarchar30) {
decimal12_t val = {999999999999999999, 999999999};
test_convert_to_varchar<decimal12_t>("Decimal", 12, val,
"999999999999999999.999999999", OLAP_SUCCESS, 30);
test_convert_to_varchar<decimal12_t>("Decimal", 12, val, "999999999999999999.999999999",
OLAP_SUCCESS, 30);
}
TEST_F(TestColumn, ConvertDecimalToVarchar29) {
decimal12_t val = {-999999999999999999, 999999999};
test_convert_to_varchar<decimal12_t>("Decimal", 12, val, "", OLAP_ERR_INPUT_PARAMETER_ERROR, 29);
test_convert_to_varchar<decimal12_t>("Decimal", 12, val, "", OLAP_ERR_INPUT_PARAMETER_ERROR,
29);
}
TEST_F(TestColumn, ConvertDecimalToVarchar31) {
decimal12_t val = {-999999999999999999, 999999999};
test_convert_to_varchar<decimal12_t>("Decimal", 12, val,
"-999999999999999999.999999999", OLAP_SUCCESS, 31);
test_convert_to_varchar<decimal12_t>("Decimal", 12, val, "-999999999999999999.999999999",
OLAP_SUCCESS, 31);
}
void CreateTabletSchema(TabletSchema& tablet_schema) {

View File

@ -31,7 +31,7 @@ TEST(function_bitmap_test, function_bitmap_min_test) {
auto empty_bitmap = new BitmapValue();
DataSet data_set = {{{bitmap1}, (int64_t)1},
{{bitmap2}, (int64_t)1},
{{empty_bitmap}, (int64_t)0},
{{empty_bitmap}, Null()},
{{Null()}, Null()}};
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
@ -48,7 +48,7 @@ TEST(function_bitmap_test, function_bitmap_max_test) {
auto empty_bitmap = new BitmapValue();
DataSet data_set = {{{bitmap1}, (int64_t)1},
{{bitmap2}, (int64_t)9999999},
{{empty_bitmap}, (int64_t)0},
{{empty_bitmap}, Null()},
{{Null()}, Null()}};
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
@ -97,10 +97,10 @@ TEST(function_bitmap_test, function_bitmap_and_count) {
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
auto empty_bitmap = new BitmapValue(); //test empty
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)0},
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)1}, //33
{{&bitmap1, &bitmap2, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)1}}; //33
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)0},
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)1}, //33
{{&bitmap1, &bitmap2, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)1}}; //33
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;
@ -128,13 +128,15 @@ TEST(function_bitmap_test, function_bitmap_or_count) {
InputTypeSet input_types = {TypeIndex::BitMap, TypeIndex::BitMap, TypeIndex::BitMap};
BitmapValue bitmap1({1024, 1, 2019});
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()}); //18446744073709551615
auto empty_bitmap = new BitmapValue(); //test empty
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()}); //18446744073709551615
auto empty_bitmap = new BitmapValue(); //test empty
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)5}, //0,1,33,1024,2019
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)7}, //0,1,5,33,1024,2019,18446744073709551615
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)5}, //0,1,33,1024,2019
{{&bitmap1, &bitmap2, &bitmap3},
(int64_t)7}, //0,1,5,33,1024,2019,18446744073709551615
{{&bitmap1, empty_bitmap, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)6}}; //1,5,33,1024,2019,18446744073709551615
{{&bitmap1, &bitmap3, &bitmap3},
(int64_t)6}}; //1,5,33,1024,2019,18446744073709551615
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;
@ -167,10 +169,11 @@ TEST(function_bitmap_test, function_bitmap_xor_count) {
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
auto empty_bitmap = new BitmapValue(); //test empty
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)5}, //0,1,33,1024,2019
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)6}, //0,1,5,1024,2019,18446744073709551615
{{&bitmap1, empty_bitmap, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)3}}; //1,1024,2019
DataSet data_set = {
{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)5}, //0,1,33,1024,2019
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)6}, //0,1,5,1024,2019,18446744073709551615
{{&bitmap1, empty_bitmap, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)3}}; //1,1024,2019
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;
@ -185,10 +188,10 @@ TEST(function_bitmap_test, function_bitmap_and_not_count) {
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
auto empty_bitmap = new BitmapValue();
DataSet data_set = {{{&bitmap1, empty_bitmap}, (int64_t)3}, //1,2,3
DataSet data_set = {{{&bitmap1, empty_bitmap}, (int64_t)3}, //1,2,3
{{&bitmap2, Null()}, Null()},
{{&bitmap2, &bitmap3}, (int64_t)3}, //0,3,4
{{&bitmap1, &bitmap2}, (int64_t)2}}; //1,2
{{&bitmap2, &bitmap3}, (int64_t)3}, //0,3,4
{{&bitmap1, &bitmap2}, (int64_t)2}}; //1,2
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;