This commit is contained in:
jsc0218 2024-10-16 02:09:10 +00:00
parent 4de51aaf4d
commit 0979723a51
3 changed files with 47 additions and 1 deletions

View File

@ -186,8 +186,13 @@ bool ParserInsertQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
const auto & children = select->as<ASTSelectWithUnionQuery>()->list_of_selects->children;
for (const auto & child : children)
{
if (child->as<ASTSelectQuery>()->getExpression(ASTSelectQuery::Expression::WITH, false))
throw Exception(ErrorCodes::SYNTAX_ERROR,
"Only one WITH should be presented, either before INSERT or SELECT.");
child->as<ASTSelectQuery>()->setExpression(ASTSelectQuery::Expression::WITH,
std::move(with_expression_list));
}
}
/// FORMAT section is expected if we have input() in SELECT part

View File

@ -8,3 +8,13 @@
2
3
4
2025-01-01
2026-01-01
2027-01-01
2028-01-01
2029-01-01
2030-01-01
2031-01-01
2032-01-01
2033-01-01
2034-01-01

View File

@ -28,4 +28,35 @@ INTERSECT
SELECT *
FROM y;
SELECT * FROM x;
SELECT * FROM x;
WITH y AS
(
SELECT *
FROM numbers(10)
)
INSERT INTO x
WITH y2 AS
(
SELECT *
FROM numbers(10)
)
SELECT * FROM y; -- { clientError SYNTAX_ERROR }
DROP TABLE x;
CREATE TABLE x (d date) ENGINE = Log;
WITH y AS
(
SELECT
number,
date_add(YEAR, number, toDate('2025-01-01')) AS new_date
FROM numbers(10)
)
INSERT INTO x
SELECT y.new_date FROM y;
SELECT * FROM x;
DROP TABLE x;