mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Try to parse DataType arguments as another nested type (#16262)
* Try to parse DataType arguments as another nested one * Allow mixed lists of arguments of data types * Restore croaring back * Fix tests
This commit is contained in:
parent
973c1d7983
commit
64bd63ca49
@ -1,13 +1,38 @@
|
|||||||
#include <Parsers/ParserDataType.h>
|
#include <Parsers/ParserDataType.h>
|
||||||
#include <Parsers/ExpressionElementParsers.h>
|
|
||||||
#include <Parsers/CommonParsers.h>
|
|
||||||
#include <Parsers/ASTFunction.h>
|
#include <Parsers/ASTFunction.h>
|
||||||
#include <Parsers/ASTIdentifier.h>
|
#include <Parsers/ASTIdentifier.h>
|
||||||
|
#include <Parsers/CommonParsers.h>
|
||||||
|
#include <Parsers/ExpressionElementParsers.h>
|
||||||
#include <Parsers/ParserCreateQuery.h>
|
#include <Parsers/ParserCreateQuery.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
/// Wrapper to allow mixed lists of nested and normal types.
|
||||||
|
class ParserNestedTableOrExpression : public IParserBase
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
const char * getName() const override { return "data type or expression"; }
|
||||||
|
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override
|
||||||
|
{
|
||||||
|
ParserNestedTable parser1;
|
||||||
|
|
||||||
|
if (parser1.parse(pos, node, expected))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ParserExpression parser2;
|
||||||
|
|
||||||
|
return parser2.parse(pos, node, expected);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||||
{
|
{
|
||||||
ParserNestedTable nested;
|
ParserNestedTable nested;
|
||||||
@ -78,7 +103,7 @@ bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
|||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
/// Parse optional parameters
|
/// Parse optional parameters
|
||||||
ParserList args_parser(std::make_unique<ParserExpression>(), std::make_unique<ParserToken>(TokenType::Comma));
|
ParserList args_parser(std::make_unique<ParserNestedTableOrExpression>(), std::make_unique<ParserToken>(TokenType::Comma));
|
||||||
ASTPtr expr_list_args;
|
ASTPtr expr_list_args;
|
||||||
|
|
||||||
if (!args_parser.parse(pos, expr_list_args, expected))
|
if (!args_parser.parse(pos, expr_list_args, expected))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
DROP TABLE IF EXISTS test_01307;
|
DROP TABLE IF EXISTS test_01307;
|
||||||
|
|
||||||
CREATE TABLE test_01307 (id UInt64, val String, INDEX ind val TYPE bloom_filter() GRANULARITY 1) ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity = 2;
|
CREATE TABLE test_01307 (id UInt64, val String, INDEX ind val TYPE bloom_filter() GRANULARITY 1) ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity = 2;
|
||||||
INSERT INTO test_01307 (id, val) select number as id, toString(number) as val from numbers(4);
|
INSERT INTO test_01307 (id, val) select number as id, toString(number) as val from numbers(4);
|
||||||
SELECT count() FROM test_01307 WHERE identity(val) = '2';
|
SELECT count() FROM test_01307 WHERE identity(val) = '2';
|
||||||
@ -6,3 +7,5 @@ SELECT count() FROM test_01307 WHERE val = '2';
|
|||||||
OPTIMIZE TABLE test_01307 FINAL;
|
OPTIMIZE TABLE test_01307 FINAL;
|
||||||
SELECT count() FROM test_01307 WHERE identity(val) = '2';
|
SELECT count() FROM test_01307 WHERE identity(val) = '2';
|
||||||
SELECT count() FROM test_01307 WHERE val = '2';
|
SELECT count() FROM test_01307 WHERE val = '2';
|
||||||
|
|
||||||
|
DROP TABLE test_01307;
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
a Tuple(key String, value String)
|
||||||
|
a Tuple(Tuple(key String, value String))
|
||||||
|
a.key Array(String)
|
||||||
|
a.value Array(String)
|
||||||
|
a Tuple(UInt8, Tuple(key String, value String))
|
21
tests/queries/0_stateless/01532_tuple_with_name_type.sql
Normal file
21
tests/queries/0_stateless/01532_tuple_with_name_type.sql
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
DROP TABLE IF EXISTS test_01532_1;
|
||||||
|
DROP TABLE IF EXISTS test_01532_2;
|
||||||
|
DROP TABLE IF EXISTS test_01532_3;
|
||||||
|
DROP TABLE IF EXISTS test_01532_4;
|
||||||
|
|
||||||
|
CREATE TABLE test_01532_1 (a Tuple(key String, value String)) ENGINE Memory();
|
||||||
|
DESCRIBE TABLE test_01532_1;
|
||||||
|
|
||||||
|
CREATE TABLE test_01532_2 (a Tuple(Tuple(key String, value String))) ENGINE Memory();
|
||||||
|
DESCRIBE TABLE test_01532_2;
|
||||||
|
|
||||||
|
CREATE TABLE test_01532_3 (a Array(Tuple(key String, value String))) ENGINE Memory();
|
||||||
|
DESCRIBE TABLE test_01532_3;
|
||||||
|
|
||||||
|
CREATE TABLE test_01532_4 (a Tuple(UInt8, Tuple(key String, value String))) ENGINE Memory();
|
||||||
|
DESCRIBE TABLE test_01532_4;
|
||||||
|
|
||||||
|
DROP TABLE test_01532_1;
|
||||||
|
DROP TABLE test_01532_2;
|
||||||
|
DROP TABLE test_01532_3;
|
||||||
|
DROP TABLE test_01532_4;
|
Loading…
Reference in New Issue
Block a user