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:
Ivan 2020-11-04 03:08:55 +03:00 committed by GitHub
parent 973c1d7983
commit 64bd63ca49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 3 deletions

View File

@ -1,13 +1,38 @@
#include <Parsers/ParserDataType.h>
#include <Parsers/ExpressionElementParsers.h>
#include <Parsers/CommonParsers.h>
#include <Parsers/ASTFunction.h>
#include <Parsers/ASTIdentifier.h>
#include <Parsers/CommonParsers.h>
#include <Parsers/ExpressionElementParsers.h>
#include <Parsers/ParserCreateQuery.h>
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)
{
ParserNestedTable nested;
@ -78,7 +103,7 @@ bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
++pos;
/// 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;
if (!args_parser.parse(pos, expr_list_args, expected))

View File

@ -1,4 +1,5 @@
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;
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';
@ -6,3 +7,5 @@ SELECT count() FROM test_01307 WHERE val = '2';
OPTIMIZE TABLE test_01307 FINAL;
SELECT count() FROM test_01307 WHERE identity(val) = '2';
SELECT count() FROM test_01307 WHERE val = '2';
DROP TABLE test_01307;

View File

@ -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))

View 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;