1+ // Licensed to the Apache Software Foundation (ASF) under one
2+ // or more contributor license agreements. See the NOTICE file
3+ // distributed with this work for additional information
4+ // regarding copyright ownership. The ASF licenses this file
5+ // to you under the Apache License, Version 2.0 (the
6+ // "License"); you may not use this file except in compliance
7+ // with the License. You may obtain a copy of the License at
8+ //
9+ // http://www.apache.org/licenses/LICENSE-2.0
10+ //
11+ // Unless required by applicable law or agreed to in writing,
12+ // software distributed under the License is distributed on an
13+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ // KIND, either express or implied. See the License for the
15+ // specific language governing permissions and limitations
16+ // under the License.
17+
18+ #include < gtest/gtest.h>
19+
20+ #include " runtime/primitive_type.h"
21+ #include " testutil/column_helper.h"
22+ #include " vec/columns/column.h"
23+ #include " vec/columns/column_array.h"
24+ #include " vec/columns/column_const.h"
25+ #include " vec/data_types/data_type_number.h"
26+ #include " vec/functions/function.h"
27+ #include " vec/functions/simple_function_factory.h"
28+
29+ namespace doris ::vectorized {
30+
31+ TEST (ColumnConstCheckTest, test1) {
32+ {
33+ ColumnPtr col = ColumnHelper::create_column<DataTypeInt32>({1 , 2 , 3 });
34+ EXPECT_EQ (col->const_nested_check (), true );
35+ }
36+
37+ {
38+ ColumnPtr col = ColumnHelper::create_column<DataTypeInt32>({1 });
39+ ColumnPtr const_col = ColumnConst::create (col, 3 );
40+ EXPECT_EQ (const_col->const_nested_check (), true );
41+ }
42+
43+ {
44+ ColumnPtr col = ColumnHelper::create_column<DataTypeInt32>({});
45+
46+ auto array_const_col = ColumnArray::create (col);
47+
48+ array_const_col->data = ColumnConst::create (col, 3 , true );
49+
50+ auto const_array = ColumnConst::create (std::move (array_const_col), 2 , true );
51+
52+ std::cout << const_array->dump_structure () << std::endl;
53+
54+ std::cout << const_array->count_const_column () << std::endl;
55+
56+ EXPECT_EQ (const_array->const_nested_check (), false );
57+ }
58+
59+ {
60+ ColumnPtr col = ColumnHelper::create_column<DataTypeInt32>({});
61+
62+ auto array_const_col = ColumnArray::create (col);
63+
64+ array_const_col->data = ColumnConst::create (col, 3 , true );
65+
66+ auto const_array = ColumnConst::create (std::move (array_const_col), 2 , true );
67+
68+ Block block;
69+ block.insert ({std::move (const_array),
70+ std::make_shared<DataTypeArray>(std::make_shared<DataTypeInt32>()),
71+ " array_col" });
72+
73+ EXPECT_FALSE (block.check_type_and_column ());
74+ }
75+ }
76+ } // namespace doris::vectorized
0 commit comments