ISSUES-1682 support insert into with select

This commit is contained in:
zhang2014 2017-12-24 17:24:10 +08:00 committed by alexey-milovidov
parent ccf7c1f760
commit 2e54dcf9b6
3 changed files with 14 additions and 1 deletions

View File

@ -33,6 +33,7 @@ bool ParserInsertQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
ParserKeyword s_values("VALUES");
ParserKeyword s_format("FORMAT");
ParserKeyword s_select("SELECT");
ParserKeyword s_with("WITH");
ParserToken s_lparen(TokenType::OpeningRoundBracket);
ParserToken s_rparen(TokenType::ClosingRoundBracket);
ParserIdentifier name_p;
@ -119,7 +120,7 @@ bool ParserInsertQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
if (data < end && *data == '\n')
++data;
}
else if (s_select.ignore(pos, expected))
else if (s_select.ignore(pos, expected) || s_with.ignore(pos,expected))
{
pos = before_select;
ParserSelectQuery select_p;

View File

@ -0,0 +1,3 @@
0 0
1 2
2 4

View File

@ -0,0 +1,9 @@
DROP TABLE IF EXISTS test.test;
CREATE TABLE test.test(number UInt64, num2 UInt64) ENGINE = Log;
INSERT INTO test.test WITH number * 2 AS num2 SELECT number, num2 FROM system.numbers LIMIT 3;
SELECT * FROM test.test;
DROP TABLE test.test;