Skip to content

Commit 74ca2b5

Browse files
committed
Fix #90
1 parent ec8a892 commit 74ca2b5

File tree

3 files changed

+71
-10
lines changed

3 files changed

+71
-10
lines changed

src/parser.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,7 @@ impl Parser {
29072907
let mut load = self.construct_node(NodeType::LoadStatement)?;
29082908
self.next_token()?; // -> DATA
29092909
load.push_node("data", self.construct_node(NodeType::Keyword)?);
2910-
self.next_token()?; // -> INTO
2910+
self.next_token()?; // -> INTO | OVERWRITE
29112911
load.push_node("into", self.construct_node(NodeType::Keyword)?);
29122912
self.next_token()?; // -> ident
29132913
load.push_node("ident", self.parse_identifier()?);
@@ -2935,12 +2935,28 @@ impl Parser {
29352935
print!("{:?}", self.construct_node(NodeType::Keyword)?);
29362936
load.push_node("from_files", self.parse_grouped_exprs(false)?);
29372937
print!("{:?}", self.construct_node(NodeType::Keyword)?);
2938-
self.next_token()?; // -> WITH
2939-
load.push_node("with", self.construct_node(NodeType::Keyword)?);
2940-
self.next_token()?; // -> CONNECTION
2941-
load.push_node("connection", self.construct_node(NodeType::Keyword)?);
2942-
self.next_token()?; // -> connection_name
2943-
load.push_node("connection_name", self.parse_identifier()?);
2938+
if self.get_token(1)?.is("WITH") && self.get_token(2)?.is("PARTITION") {
2939+
self.next_token()?; // -> WITH
2940+
let mut with = self.construct_node(NodeType::WithPartitionColumnsClause)?;
2941+
self.next_token()?; // -> PARTITION
2942+
with.push_node_vec("partition_columns", self.parse_n_keywords(2)?);
2943+
if self.get_token(1)?.is("(") {
2944+
self.next_token()?; // -> (
2945+
with.push_node(
2946+
"column_schema_group",
2947+
self.parse_grouped_type_declarations(false)?,
2948+
);
2949+
}
2950+
load.push_node("with_partition_columns", with);
2951+
}
2952+
if self.get_token(1)?.is("WITH") && self.get_token(2)?.is("CONNECTION") {
2953+
self.next_token()?; // -> WITH
2954+
load.push_node("with", self.construct_node(NodeType::Keyword)?);
2955+
self.next_token()?; // -> CONNECTION
2956+
load.push_node("connection", self.construct_node(NodeType::Keyword)?);
2957+
self.next_token()?; // -> connection_name
2958+
load.push_node("connection_name", self.parse_identifier()?);
2959+
}
29442960

29452961
if self.get_token(1)?.is(";") && semicolon {
29462962
self.next_token()?; // -> ;

src/parser/tests/tests_other.rs

+44
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,50 @@ partitionby:
171171
- self: dt (Identifier)
172172
with:
173173
self: WITH (Keyword)
174+
",
175+
0,
176+
)),
177+
Box::new(SuccessTestCase::new(
178+
"\
179+
LOAD DATA OVERWRITE ident
180+
FROM FILES (dummy = 'dummy')
181+
WITH PARTITION COLUMNS (x STRING)
182+
",
183+
"\
184+
self: LOAD (LoadStatement)
185+
data:
186+
self: DATA (Keyword)
187+
files:
188+
self: FILES (Keyword)
189+
from:
190+
self: FROM (Keyword)
191+
from_files:
192+
self: ( (GroupedExprs)
193+
exprs:
194+
- self: = (BinaryOperator)
195+
left:
196+
self: dummy (Identifier)
197+
right:
198+
self: 'dummy' (StringLiteral)
199+
rparen:
200+
self: ) (Symbol)
201+
ident:
202+
self: ident (Identifier)
203+
into:
204+
self: OVERWRITE (Keyword)
205+
with_partition_columns:
206+
self: WITH (WithPartitionColumnsClause)
207+
column_schema_group:
208+
self: ( (GroupedTypeDeclarations)
209+
declarations:
210+
- self: x (TypeDeclaration)
211+
type:
212+
self: STRING (Type)
213+
rparen:
214+
self: ) (Symbol)
215+
partition_columns:
216+
- self: PARTITION (Keyword)
217+
- self: COLUMNS (Keyword)
174218
",
175219
0,
176220
)),

src/types.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -921,9 +921,10 @@ export type LoadStatement = XXXStatement & {
921921
from: NodeChild;
922922
files: NodeChild;
923923
from_files: NodeChild;
924-
with: NodeChild;
925-
connection: NodeChild;
926-
connection_name: NodeChild;
924+
with_partition_columns?: NodeChild;
925+
with?: NodeChild;
926+
connection?: NodeChild;
927+
connection_name?: NodeChild;
927928
};
928929
};
929930

0 commit comments

Comments
 (0)