Skip to content

Commit c1c77d3

Browse files
committed
fix: insert_stmt allow ; at the end.
1 parent d6ddbae commit c1c77d3

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/query/ast/src/parser/statement.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,9 +2989,9 @@ pub fn insert_source_file(i: Input) -> IResult<InsertSource> {
29892989
);
29902990
map(
29912991
rule! {
2992-
(VALUES ~ #value?)? ~ FROM ~ #at_string ~ #file_format_clause
2992+
(VALUES ~ #value?)? ~ FROM ~ #at_string ~ #file_format_clause ~ ";"? ~ &EOI
29932993
},
2994-
|(values, _, location, format_options)| InsertSource::LoadFile {
2994+
|(values, _, location, format_options, _, _)| InsertSource::LoadFile {
29952995
value: values.map(|(_, value)| value).unwrap_or_default(),
29962996
location,
29972997
format_options,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
>>>> create or replace table t_09_0002 (a int)
2+
<<<<
3+
"Succeeded"
4+
null
5+
"Succeeded"
6+
null
7+
"Succeeded"
8+
null
9+
"Succeeded"
10+
null
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
4+
. "$CURDIR"/../../../shell_env.sh
5+
6+
query "create or replace table t_09_0002 (a int)"
7+
8+
# insert_stmt
9+
curl -s --header 'Content-Type: application/json' --request POST '127.0.0.1:8000/v1/query/' --data-raw '{"sql": "insert into t_09_0002 from @~/not_exist file_format=(type=csv);", "pagination": { "wait_time_secs": 5}}' -u root: | jq -c ".state",".error"
10+
curl -s --header 'Content-Type: application/json' --request POST '127.0.0.1:8000/v1/query/' --data-raw '{"sql": "insert into t_09_0002 select 1;", "pagination": { "wait_time_secs": 5}}' -u root: | jq -c ".state",".error"
11+
curl -s --header 'Content-Type: application/json' --request POST '127.0.0.1:8000/v1/query/' --data-raw '{"sql": "insert into t_09_0002 values (1);", "pagination": { "wait_time_secs": 5}}' -u root: | jq -c ".state",".error"
12+
13+
# statement
14+
curl -s --header 'Content-Type: application/json' --request POST '127.0.0.1:8000/v1/query/' --data-raw '{"sql": "select 1;", "pagination": { "wait_time_secs": 2}}' -u root: | jq -c ".state",".error"

0 commit comments

Comments
 (0)