forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgtest_NestedUtils.cpp
More file actions
43 lines (37 loc) · 1.28 KB
/
gtest_NestedUtils.cpp
File metadata and controls
43 lines (37 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <DataTypes/NestedUtils.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypeNested.h>
#include <gtest/gtest.h>
using namespace DB;
GTEST_TEST(NestedUtils, collect)
{
DataTypePtr uint_type = std::make_shared<DataTypeUInt32>();
DataTypePtr array_type = std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt32>());
const NamesAndTypesList source_columns =
{
{"id", uint_type},
{"arr1", array_type},
{"b.id", uint_type},
{"b.arr1", array_type},
{"b.arr2", array_type}
};
auto nested_type = createNested({uint_type, uint_type}, {"arr1", "arr2"});
const NamesAndTypesList columns_with_subcolumns =
{
{"id", uint_type},
{"arr1", array_type},
{"b.id", uint_type},
{"b", "arr1", nested_type, array_type},
{"b", "arr2", nested_type, array_type}
};
const NamesAndTypesList columns_with_nested =
{
{"id", uint_type},
{"arr1", array_type},
{"b.id", uint_type},
{"b", nested_type},
};
ASSERT_EQ(Nested::convertToSubcolumns(source_columns).toString(), columns_with_subcolumns.toString());
ASSERT_EQ(Nested::collect(source_columns).toString(), columns_with_nested.toString());
}