Skip to content

Commit

Permalink
catch up some case
Browse files Browse the repository at this point in the history
  • Loading branch information
amorynan committed Jan 3, 2025
1 parent 8019768 commit d637e16
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
6 changes: 1 addition & 5 deletions be/test/vec/data_types/common_data_type_serder_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,14 @@ class CommonDataTypeSerdeTest : public ::testing::Test {

while (std::getline(file, line)) {
std::stringstream lineStream(line);
// std::cout << "whole : " << lineStream.str() << std::endl;
std::string value;
int l_idx = 0;
int c_idx = 0;
std::vector<std::string> row;
while (std::getline(lineStream, value, spliter)) {
if (idxes.contains(l_idx)) {
if (!value.starts_with("//") && idxes.contains(l_idx)) {
// load csv data
Slice string_slice(value.data(), value.size());
std::cout << "origin : " << string_slice << std::endl;
Status st;
// deserialize data
if constexpr (is_hive_format) {
Expand Down Expand Up @@ -210,8 +208,6 @@ class CommonDataTypeSerdeTest : public ::testing::Test {
}
for (size_t r = 0; r < assert_str_cols[0]->size(); ++r) {
for (size_t c = 0; c < assert_str_cols.size(); ++c) {
std::cout << assert_str_cols[c]->get_data_at(r).to_string() << spliter
<< std::endl;
res_f << assert_str_cols[c]->get_data_at(r).to_string() << spliter;
}
res_f << std::endl;
Expand Down
77 changes: 65 additions & 12 deletions be/test/vec/data_types/data_type_array_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
// specific language governing permissions and limitations
// under the License.

#include <execinfo.h> // for backtrace on Linux
#include <gtest/gtest-message.h>
#include <gtest/gtest-test-part.h>
#include <gtest/gtest.h>

#include <filesystem>
#include <iostream>
#include <stdexcept>

#include "vec/columns/column.h"
#include "vec/columns/columns_number.h"
Expand Down Expand Up @@ -262,11 +264,6 @@ class DataTypeArrayTest : public CommonDataTypeTest {
array_types.push_back(type);
serdes.push_back(serde);
}
// step3. show array column data
for (int i = 0; i < array_columns.size(); i++) {
// auto& column = array_columns[i];
// printColumn(*column, *descs[i][0].data_type);
}
}

std::string data_file_dir = "regression-test/data/nereids_function_p0/array/";
Expand Down Expand Up @@ -304,7 +301,7 @@ class DataTypeArrayTest : public CommonDataTypeTest {
data_file_dir + "test_array_array_decimalv3(27,9).csv",
data_file_dir + "test_array_array_decimalv3(38,30).csv",
data_file_dir + "test_array_array_decimalv3(76,56).csv",
// array-map
// array-map - 36
data_file_dir + "test_array_map<char,double>.csv",
data_file_dir + "test_array_map<datetime,decimal<76,56>>.csv",
data_file_dir + "test_array_map<ipv4,ipv6>.csv",
Expand Down Expand Up @@ -369,11 +366,52 @@ TEST_F(DataTypeArrayTest, CreateColumnTest) {
create_column_assert(type, default_field_array, 24);
}
// for decimal32/64/128/256 here uncompressed size is 16
for (int i = 14; i < array_types.size(); i++) {
// one scalar type
for (int i = 14; i < 18; i++) {
auto type = remove_nullable(array_types[i]);
Field default_field_array = Array();
create_column_assert(type, default_field_array, 16);
}
// for array-array-scala
for (int i = 18; i < 31; i++) {
auto type = remove_nullable(array_types[i]);
Field default_field_array = Array();
create_column_assert(type, default_field_array, 28);
}
{
// string type
auto type = remove_nullable(array_types[31]);
Field default_field_array = Array();
create_column_assert(type, default_field_array, 36);
}
for (int i = 32; i < 36; i++) {
auto type = remove_nullable(array_types[i]);
Field default_field_array = Array();
create_column_assert(type, default_field_array, 28);
}
// for array-map
{
auto type = remove_nullable(array_types[36]);
Field default_field_array = Array();
create_column_assert(type, default_field_array, 44);
type = remove_nullable(array_types[39]);
default_field_array = Array();
create_column_assert(type, default_field_array, 44);
}
{
auto type = remove_nullable(array_types[37]);
Field default_field_array = Array();
create_column_assert(type, default_field_array, 36);
type = remove_nullable(array_types[38]);
default_field_array = Array();
create_column_assert(type, default_field_array, 36);
}
// for array-struct
{
auto type = remove_nullable(array_types[40]);
Field default_field_array = Array();
create_column_assert(type, default_field_array, 76);
}
}

TEST_F(DataTypeArrayTest, GetFieldTest) {
Expand All @@ -394,7 +432,7 @@ TEST_F(DataTypeArrayTest, FromAndToStringTest) {
std::cout << "type: " << type->get_name() << " for column size: " << column->size()
<< std::endl;
// datatype array<string> has some different behavior maybe wrong with given data
if (i == 13) {
if (i == 13 || i == 31) {
continue;
}
assert_to_string_from_string_assert(column->assume_mutable(), type);
Expand All @@ -413,9 +451,10 @@ TEST_F(DataTypeArrayTest, CompareTest) {

TEST_F(DataTypeArrayTest, SerdeHiveTextAndJsonFormatTest) {
// insert from data csv and assert insert result
for (int i = 0; i < array_types.size(); i++) {
for (int i = 0; i < 40; i++) {
MutableColumns array_cols;
array_cols.push_back(array_columns[i]->get_ptr());
// array-struct would cause be core:heap-buffer-overflow for hive_text deser as '[]'
CommonDataTypeSerdeTest::load_data_and_assert_from_csv<true, true>({serdes[i]}, array_cols,
data_files[i], ';');
CommonDataTypeSerdeTest::load_data_and_assert_from_csv<false, true>({serdes[i]}, array_cols,
Expand All @@ -425,7 +464,13 @@ TEST_F(DataTypeArrayTest, SerdeHiveTextAndJsonFormatTest) {

TEST_F(DataTypeArrayTest, SerdePbTest) {
// fix serde pb for read decimal64 not support
CommonDataTypeSerdeTest::assert_pb_format(array_columns, serdes);
MutableColumns array_cols;
DataTypeSerDeSPtrs serdes_pb;
for (int i = 0; i < 40; i++) {
array_cols.push_back(array_columns[i]->get_ptr());
serdes_pb.push_back(serdes[i]);
}
CommonDataTypeSerdeTest::assert_pb_format(array_cols, serdes_pb);
}

TEST_F(DataTypeArrayTest, SerdeJsonbTest) {
Expand Down Expand Up @@ -479,11 +524,19 @@ TEST_F(DataTypeArrayTest, SerdeArrowTest) {

//================== datatype for array ut test ==================
TEST_F(DataTypeArrayTest, GetNumberOfDimensionsTest) {
for (int i = 0; i < array_types.size(); i++) {
for (int i = 0; i < array_types.size() - 5; i++) {
auto& type = array_types[i];
auto desc = array_descs[i];
auto array_type = assert_cast<const DataTypeArray*>(remove_nullable(type).get());
EXPECT_EQ(array_type->get_number_of_dimensions(), desc.size());
// array dimension is only for array to nested array , if array nested map or struct, the dimension also be is 1
EXPECT_EQ(array_type->get_number_of_dimensions(), desc.size())
<< "for type: " << type->get_name() << " desc size: " << desc.size();
}
for (int i = 36; i < 41; i++) {
auto& type = array_types[i];
auto array_type = assert_cast<const DataTypeArray*>(remove_nullable(type).get());
// array dimension is only for array to nested array , if array nested map or struct, the dimension also be is 1
EXPECT_EQ(array_type->get_number_of_dimensions(), 1) << "for type: " << type->get_name();
}
}

Expand Down
2 changes: 1 addition & 1 deletion be/test/vec/data_types/data_type_ip_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST_F(DataTypeIPTest, MetaInfoTest) {
.is_null_literal = false,
.is_value_represented_by_number = true,
.pColumnMeta = col_meta6.get(),
.default_field = Int128(0)
.default_field = IPv6(0)
// .is_value_unambiguously_represented_in_contiguous_memory_region = true
};
meta_info_assert(dt_ipv4, ipv4_meta_info_to_assert);
Expand Down

0 comments on commit d637e16

Please sign in to comment.