address 01825_type_json_18 test

This commit is contained in:
Sema Checherinda 2022-09-16 15:45:21 +02:00
parent dc19141d84
commit 8977e499c2
6 changed files with 40 additions and 2 deletions

View File

@ -981,4 +981,18 @@ Field FieldVisitorFoldDimension::operator()(const Array & x) const
return res;
}
DataTypePtr makeDummyTupleTypeForObject()
{
return std::make_shared<DataTypeTuple>(
DataTypes{std::make_shared<DataTypeUInt8>()},
Names{ColumnObject::COLUMN_NAME_DUMMY});
}
void setAllObjectsToDummyTupleType(NamesAndTypesList & columns)
{
for (auto & column : columns)
if (column.type->hasDynamicSubcolumns())
column.type = createConcreteEmptyDynamicColumn(column.type);
}
}

View File

@ -162,6 +162,8 @@ private:
size_t num_dimensions_to_fold;
};
void setAllObjectsToDummyTupleType(NamesAndTypesList & columns);
/// Receives range of objects, which contains collections
/// of columns-like objects (e.g. ColumnsDescription or NamesAndTypesList)
/// and deduces the common types of object columns for all entries.

View File

@ -7253,7 +7253,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeData::createEmptyPart(MergeTreePartIn
auto block = metadata_snapshot->getSampleBlock();
NamesAndTypesList columns = metadata_snapshot->getColumns().getAllPhysical().filter(block.getNames());
extendObjectColumns(columns, object_columns, /*with_subcolumns*/ false);
setAllObjectsToDummyTupleType(columns);
DB::IMergeTreeDataPart::TTLInfos move_ttl_infos;
ReservationPtr reservation = reserveSpacePreferringTTLRules(metadata_snapshot, 0, move_ttl_infos, time(nullptr), 0, true);

View File

@ -6,22 +6,26 @@ all_2_2_0 data Tuple(k5 String)
all_1_2_1 data Tuple(k1 String, k2 Tuple(k3 String, k4 String), k5 String)
============
1 ['aaa','ddd'] [['bbb','ccc'],['eee','fff']]
all_1_2_2 data Tuple(_dummy UInt8)
all_3_3_0 data Tuple(k1 Nested(k2 String, k3 Nested(k4 String)))
============
1 a 42
2 b 4200
4242
all_1_3_3 data Tuple(_dummy UInt8)
all_4_4_0 data Tuple(name String, value Int16)
1 a 42
2 b 4200
3 a 42.123
all_1_3_3 data Tuple(_dummy UInt8)
all_4_4_0 data Tuple(name String, value Int16)
all_5_5_0 data Tuple(name String, value Float64)
1 a 42
2 b 4200
3 a 42.123
4 a some
all_1_3_3 data Tuple(_dummy UInt8)
all_4_4_0 data Tuple(name String, value Int16)
all_5_5_0 data Tuple(name String, value Float64)
all_6_6_0 data Tuple(name String, value String)
all_4_6_1 data Tuple(name String, value String)
all_1_6_4 data Tuple(name String, value String)

View File

@ -0,0 +1,2 @@
1 (1) Tuple(k1 Int8)
1 ([1,2]) Tuple(k1 Array(Int8))

View File

@ -0,0 +1,16 @@
-- Tags: no-fasttest
SET allow_experimental_object_type = 1;
DROP TABLE IF EXISTS t_json_2;
CREATE TABLE t_json_2(id UInt64, data Object('JSON'))
ENGINE = MergeTree ORDER BY tuple();
INSERT INTO t_json_2 FORMAT JSONEachRow {"id": 1, "data" : {"k1": 1}};
SELECT id, data, toTypeName(data) FROM t_json_2 ORDER BY id;
TRUNCATE TABLE t_json_2;
INSERT INTO t_json_2 FORMAT JSONEachRow {"id": 1, "data" : {"k1": [1, 2]}};
SELECT id, data, toTypeName(data) FROM t_json_2 ORDER BY id;