Skip to content

Commit e3e1627

Browse files
authored
Parse TABLE <id> references (#333)
1 parent b493f22 commit e3e1627

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

partiql-ast/src/ast.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ pub enum QuerySet {
265265
Select(Box<AstNode<Select>>),
266266
Expr(Box<Expr>),
267267
Values(Vec<Box<Expr>>),
268+
Table(QueryTable),
268269
}
269270

270271
#[derive(Visit, Clone, Debug, PartialEq)]
@@ -308,6 +309,13 @@ pub struct Select {
308309
pub having: Option<Box<AstNode<HavingClause>>>,
309310
}
310311

312+
#[derive(Visit, Clone, Debug, PartialEq, Eq)]
313+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
314+
pub struct QueryTable {
315+
#[visit(skip)]
316+
pub table_name: SymbolPrimitive,
317+
}
318+
311319
#[derive(Visit, Clone, Debug, PartialEq)]
312320
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
313321
pub struct Projection {

partiql-ast/src/visit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ pub trait Visitor<'ast> {
128128
fn exit_set_expr(&mut self, _set_expr: &'ast ast::SetExpr) {}
129129
fn enter_select(&mut self, _select: &'ast ast::Select) {}
130130
fn exit_select(&mut self, _select: &'ast ast::Select) {}
131+
fn enter_query_table(&mut self, _table: &'ast ast::QueryTable) {}
132+
fn exit_query_table(&mut self, _table: &'ast ast::QueryTable) {}
131133
fn enter_projection(&mut self, _projection: &'ast ast::Projection) {}
132134
fn exit_projection(&mut self, _projection: &'ast ast::Projection) {}
133135
fn enter_projection_kind(&mut self, _projection_kind: &'ast ast::ProjectionKind) {}

partiql-logical-planner/src/lower.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ impl<'ast> Visitor<'ast> for AstToLogical {
532532
QuerySet::Select(_) => {}
533533
QuerySet::Expr(_) => {}
534534
QuerySet::Values(_) => todo!("QuerySet::Values"),
535+
QuerySet::Table(_) => todo!("QuerySet::Table"),
535536
}
536537
}
537538

@@ -550,6 +551,7 @@ impl<'ast> Visitor<'ast> for AstToLogical {
550551
self.push_bexpr(id);
551552
}
552553
QuerySet::Values(_) => todo!("QuerySet::Values"),
554+
QuerySet::Table(_) => todo!("QuerySet::Table"),
553555
}
554556
}
555557

partiql-parser/src/parse/partiql.lalrpop

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ SingleQuery: ast::AstNode<ast::QuerySet> = {
139139
},
140140
<lo:@L> <sfw:SfwQuery> <hi:@R> => state.node(ast::QuerySet::Select( Box::new(sfw)), lo..hi),
141141
<lo:@L> <values:Values> <hi:@R> => values,
142+
<lo:@L> <table:ExplicitTable> <hi:@R> => table,
142143
}
143144

144145
Values: ast::AstNode<ast::QuerySet> = {
@@ -151,6 +152,11 @@ ValueRow: Box<ast::Expr> = {
151152
<array:ExprTermCollection> => Box::new(array)
152153
}
153154

155+
#[inline]
156+
ExplicitTable: ast::AstNode<ast::QuerySet> = {
157+
<lo:@L> "TABLE" <table_name:SymbolPrimitive> <hi:@R> => state.node(ast::QuerySet::Table( ast::QueryTable{table_name} ), lo..hi)
158+
}
159+
154160
// ------------------------------------------------------------------------------ //
155161
// //
156162
// SFW Query //

0 commit comments

Comments
 (0)