Skip to content

Commit d4e222a

Browse files
committed
sql_parser: expression parser refactoring (10)
1 parent 13cb9f8 commit d4e222a

File tree

3 files changed

+175
-128
lines changed

3 files changed

+175
-128
lines changed

src/parser/expression/mod.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,28 @@ impl<'a> ExpressionParser for Parser<'a> {
129129
pub(crate) mod test_utils {
130130
use crate::ast::{Expression, SelectItem};
131131
use crate::{
132-
BinaryOp, CollateExpressionStatement, DataType, ExistsStatement, Function, FunctionArg,
133-
Identifier, LiteralValue, OverClause, Parser, RaiseFunction, SelectBody, SelectStatement,
134-
Statement, UnaryOp,
132+
BinaryOp, CollateExpressionStatement, DataType, DistinctType, ExistsStatement, Function,
133+
FunctionArg, Identifier, LiteralValue, OverClause, Parser, RaiseFunction, Select,
134+
SelectBody, SelectStatement, Statement, UnaryOp,
135135
};
136136

137+
pub fn select_expr(expression: Expression) -> SelectStatement {
138+
SelectStatement {
139+
with_cte: None,
140+
select: SelectBody::Select(Select {
141+
distinct_type: DistinctType::None,
142+
columns: vec![SelectItem::Expression(expression)],
143+
from: None,
144+
where_clause: None,
145+
group_by: None,
146+
having: None,
147+
window: None,
148+
}),
149+
order_by: None,
150+
limit: None,
151+
}
152+
}
153+
137154
pub fn run_sunny_day_test_with_multiple_expressions(
138155
sql: &str,
139156
expected_expressions: &[&Expression],

0 commit comments

Comments
 (0)