diff --git a/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java b/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java index 6a2d76b190..0e138ca018 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java +++ b/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java @@ -5896,6 +5896,9 @@ public class SQLStatementParser extends SQLParser { for (int i = 0; ; ++i) { int startPos = lexer.pos - 1; + if (lexer.token == Token.ROW) { + lexer.nextToken(); + } if (lexer.token != Token.LPAREN) { throw new ParserException("syntax error, expect ')', " + lexer.info()); } diff --git a/src/test/resources/bvt/parser/clickhouse-4.txt b/src/test/resources/bvt/parser/clickhouse-4.txt new file mode 100644 index 0000000000..ac424d3ccd --- /dev/null +++ b/src/test/resources/bvt/parser/clickhouse-4.txt @@ -0,0 +1,24 @@ +SELECT + sum(r[1]) AS r1, + sum(r[2]) AS r2 + FROM + ( + WITH subtractDays(toDate('2021-01-19'), 1) AS day + SELECT + retention(toDate(created) = day, + toDate(created) = '2021-01-19' + ) AS r + FROM user_action_logs + WHERE toDate(created) IN(day, '2021-01-19') + GROUP BY member_id + ) +--------------------------- +CREATE TABLE visits ( + time DateTime, + visits NESTED ( + a String, + btime Int64, + c String, + e String + ) +) ENGINE = Memory; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/hive-6.txt b/src/test/resources/bvt/parser/hive-6.txt new file mode 100644 index 0000000000..4f94821063 --- /dev/null +++ b/src/test/resources/bvt/parser/hive-6.txt @@ -0,0 +1,16 @@ +WITH A AS ( + WITH A1 AS ( + SELECT * + FROM aaa1226.t123 + LIMIT 1 + ) + SELECT * + FROM A1 + ), + B AS ( + SELECT * + FROM aaa1226.t123 + LIMIT 1 + ) +SELECT * +FROM A, B \ No newline at end of file diff --git a/src/test/resources/bvt/parser/mysql-20.txt b/src/test/resources/bvt/parser/mysql-20.txt new file mode 100644 index 0000000000..5ba4691969 --- /dev/null +++ b/src/test/resources/bvt/parser/mysql-20.txt @@ -0,0 +1,7 @@ +INSERT INTO ex VALUES + ROW(CURRENT_TIMESTAMP), + ROW('2020-07-31 21:44:30-08:00'); +--------------------------- +INSERT INTO ex +VALUES (CURRENT_TIMESTAMP), + ('2020-07-31 21:44:30-08:00'); \ No newline at end of file diff --git a/src/test/resources/bvt/parser/mysql-21.txt b/src/test/resources/bvt/parser/mysql-21.txt new file mode 100644 index 0000000000..7b9a1a35f9 --- /dev/null +++ b/src/test/resources/bvt/parser/mysql-21.txt @@ -0,0 +1,4 @@ +INSERT INTO name () VALUES (); +--------------------------- +INSERT INTO name +VALUES (); \ No newline at end of file diff --git a/src/test/resources/bvt/parser/mysql-22.txt b/src/test/resources/bvt/parser/mysql-22.txt new file mode 100644 index 0000000000..7e79ba8ba4 --- /dev/null +++ b/src/test/resources/bvt/parser/mysql-22.txt @@ -0,0 +1,9 @@ +CREATE TABLE inventory( + items JSON, + INDEX i1 ( (JSON_VALUE(items, '$.name' RETURNING VARCHAR(50))) ), + INDEX i2 ( (JSON_VALUE(items, '$.price' RETURNING DECIMAL(5,2))) ), + INDEX i3 ( (JSON_VALUE(items, '$.quantity' RETURNING UNSIGNED)) ) +); +--------------------------- +INSERT INTO name +VALUES (); \ No newline at end of file diff --git a/src/test/resources/bvt/parser/trino-0.txt b/src/test/resources/bvt/parser/trino-0.txt new file mode 100644 index 0000000000..1557ef6b63 --- /dev/null +++ b/src/test/resources/bvt/parser/trino-0.txt @@ -0,0 +1,10 @@ +select *, + row_number() over w1 +from +( + VALUES + (1, 'a'), + (2, 'b'), + (3, 'c') +) AS t (id, name) +window w1 as (partition by 1 order by id) \ No newline at end of file