mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
add test for variant subcolumn
This commit is contained in:
parent
66b39b11a2
commit
bac29c0bba
@ -124,6 +124,12 @@ void RewriteFunctionToSubcolumnFirstPassMatcher::visit(const ASTFunction & funct
|
||||
if (value_type == Field::Types::UInt64 || value_type == Field::Types::String)
|
||||
++data.optimized_identifiers_count[column->name];
|
||||
}
|
||||
else if (function.name == "variantElement" && column_type_id == TypeIndex::Variant)
|
||||
{
|
||||
const auto * literal = arguments[1]->as<ASTLiteral>();
|
||||
if (literal && literal->value.getType() == Field::Types::String)
|
||||
++data.optimized_identifiers_count[column->name];
|
||||
}
|
||||
else if (function.name == "mapContains" && column_type_id == TypeIndex::Map)
|
||||
{
|
||||
++data.optimized_identifiers_count[column->name];
|
||||
|
@ -0,0 +1,8 @@
|
||||
SELECT `v.String` AS `variantElement(v, \'String\')`
|
||||
FROM t_func_to_subcolumns_variant
|
||||
foo
|
||||
\N
|
||||
SELECT __table1.`v.String` AS `variantElement(v, \'String\')`
|
||||
FROM default.t_func_to_subcolumns_variant AS __table1
|
||||
foo
|
||||
\N
|
@ -0,0 +1,21 @@
|
||||
DROP TABLE IF EXISTS t_func_to_subcolumns_variant;
|
||||
|
||||
SET allow_experimental_variant_type = 1;
|
||||
|
||||
CREATE TABLE t_func_to_subcolumns_variant (id UInt64, v Variant(String, UInt64)) ENGINE = MergeTree ORDER BY id;
|
||||
|
||||
INSERT INTO t_func_to_subcolumns_variant VALUES (1, 'foo') (2, 111);
|
||||
|
||||
SET optimize_functions_to_subcolumns = 1;
|
||||
SET allow_experimental_analyzer = 0;
|
||||
|
||||
EXPLAIN SYNTAX SELECT variantElement(v, 'String') FROM t_func_to_subcolumns_variant;
|
||||
SELECT variantElement(v, 'String') FROM t_func_to_subcolumns_variant;
|
||||
|
||||
SET optimize_functions_to_subcolumns = 1;
|
||||
SET allow_experimental_analyzer = 1;
|
||||
|
||||
EXPLAIN QUERY TREE dump_tree = 0, dump_ast = 1 SELECT variantElement(v, 'String') FROM t_func_to_subcolumns_variant;
|
||||
SELECT variantElement(v, 'String') FROM t_func_to_subcolumns_variant;
|
||||
|
||||
DROP TABLE t_func_to_subcolumns_variant;
|
Loading…
Reference in New Issue
Block a user