Merge pull request #16768 from ClickHouse/better-diagnostic-on-create-syntax-error

Better diagnostics on syntax error in CREATE TABLE query
This commit is contained in:
alexey-milovidov 2020-11-08 14:28:33 +03:00 committed by GitHub
commit 8289fe7b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -144,8 +144,8 @@ bool IParserColumnDeclaration<NameParser>::parseImpl(Pos & pos, ASTPtr & node, E
/// doesn't check that parsed string is existing data type. In this way /// doesn't check that parsed string is existing data type. In this way
/// REMOVE keyword can be parsed as data type and further parsing will fail. /// REMOVE keyword can be parsed as data type and further parsing will fail.
/// So we just check this keyword and in case of success return column /// So we just check this keyword and in case of success return column
/// column declaration with name only. /// declaration with name only.
if (s_remove.checkWithoutMoving(pos, expected)) if (!require_type && s_remove.checkWithoutMoving(pos, expected))
{ {
if (!check_keywords_after_name) if (!check_keywords_after_name)
return false; return false;
@ -165,11 +165,12 @@ bool IParserColumnDeclaration<NameParser>::parseImpl(Pos & pos, ASTPtr & node, E
ASTPtr codec_expression; ASTPtr codec_expression;
ASTPtr ttl_expression; ASTPtr ttl_expression;
if (!s_default.checkWithoutMoving(pos, expected) && if (!s_default.checkWithoutMoving(pos, expected)
!s_materialized.checkWithoutMoving(pos, expected) && && !s_materialized.checkWithoutMoving(pos, expected)
!s_alias.checkWithoutMoving(pos, expected) && && !s_alias.checkWithoutMoving(pos, expected)
!s_comment.checkWithoutMoving(pos, expected) && && (require_type
!s_codec.checkWithoutMoving(pos, expected)) || (!s_comment.checkWithoutMoving(pos, expected)
&& !s_codec.checkWithoutMoving(pos, expected))))
{ {
if (!type_parser.parse(pos, type, expected)) if (!type_parser.parse(pos, type, expected))
return false; return false;

View File

@ -0,0 +1 @@
Unknown data type family: CODEC

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
${CLICKHOUSE_CLIENT} --query "CREATE TABLE t (c CODEC(NONE)) ENGINE = Memory" 2>&1 | grep -oF 'Unknown data type family: CODEC' | uniq