Skip to content

Commit f92bbd8

Browse files
committed
Cargo fmt
1 parent 6021ecc commit f92bbd8

File tree

10 files changed

+909
-735
lines changed

10 files changed

+909
-735
lines changed

src/parser/mod.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,7 +2425,8 @@ impl<'a> Parser<'a> {
24252425
null_treatment: None,
24262426
over: None,
24272427
within_group: vec![],
2428-
}.into());
2428+
}
2429+
.into());
24292430
}
24302431

24312432
let mut args = self.parse_function_argument_list()?;
@@ -2493,7 +2494,8 @@ impl<'a> Parser<'a> {
24932494
filter,
24942495
over,
24952496
within_group,
2496-
}.into())
2497+
}
2498+
.into())
24972499
}
24982500

24992501
/// Optionally parses a null treatment clause.
@@ -2519,16 +2521,19 @@ impl<'a> Parser<'a> {
25192521
} else {
25202522
FunctionArguments::None
25212523
};
2522-
Ok(Expr::Function(Function {
2523-
name,
2524-
uses_odbc_syntax: false,
2525-
parameters: FunctionArguments::None,
2526-
args,
2527-
filter: None,
2528-
over: None,
2529-
null_treatment: None,
2530-
within_group: vec![],
2531-
}.into()))
2524+
Ok(Expr::Function(
2525+
Function {
2526+
name,
2527+
uses_odbc_syntax: false,
2528+
parameters: FunctionArguments::None,
2529+
args,
2530+
filter: None,
2531+
over: None,
2532+
null_treatment: None,
2533+
within_group: vec![],
2534+
}
2535+
.into(),
2536+
))
25322537
}
25332538

25342539
/// Parse window frame `UNITS` clause: `ROWS`, `RANGE`, or `GROUPS`.
@@ -13839,7 +13844,10 @@ impl<'a> Parser<'a> {
1383913844
let function_expr = self.parse_function(function_name)?;
1384013845
if let Expr::Function(function) = function_expr {
1384113846
let alias = self.parse_identifier_optional_alias()?;
13842-
pipe_operators.push(PipeOperator::Call { function: *function, alias });
13847+
pipe_operators.push(PipeOperator::Call {
13848+
function: *function,
13849+
alias,
13850+
});
1384313851
} else {
1384413852
return Err(ParserError::ParserError(
1384513853
"Expected function call after CALL".to_string(),

src/test_utils.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -435,23 +435,26 @@ pub fn join(relation: TableFactor) -> Join {
435435
}
436436

437437
pub fn call(function: &str, args: impl IntoIterator<Item = Expr>) -> Expr {
438-
Expr::Function(Function {
439-
name: ObjectName::from(vec![Ident::new(function)]),
440-
uses_odbc_syntax: false,
441-
parameters: FunctionArguments::None,
442-
args: FunctionArguments::List(FunctionArgumentList {
443-
duplicate_treatment: None,
444-
args: args
445-
.into_iter()
446-
.map(|arg| FunctionArg::Unnamed(FunctionArgExpr::Expr(arg)))
447-
.collect(),
448-
clauses: vec![],
449-
}),
450-
filter: None,
451-
null_treatment: None,
452-
over: None,
453-
within_group: vec![],
454-
}.into())
438+
Expr::Function(
439+
Function {
440+
name: ObjectName::from(vec![Ident::new(function)]),
441+
uses_odbc_syntax: false,
442+
parameters: FunctionArguments::None,
443+
args: FunctionArguments::List(FunctionArgumentList {
444+
duplicate_treatment: None,
445+
args: args
446+
.into_iter()
447+
.map(|arg| FunctionArg::Unnamed(FunctionArgExpr::Expr(arg)))
448+
.collect(),
449+
clauses: vec![],
450+
}),
451+
filter: None,
452+
null_treatment: None,
453+
over: None,
454+
within_group: vec![],
455+
}
456+
.into(),
457+
)
455458
}
456459

457460
/// Gets the first index column (mysql calls it a key part) of the first index found in a

tests/sqlparser_bigquery.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,25 +2229,28 @@ fn parse_map_access_expr() {
22292229
},
22302230
}),
22312231
AccessExpr::Subscript(Subscript::Index {
2232-
index: Expr::Function(Function {
2233-
name: ObjectName::from(vec![Ident::with_span(
2234-
Span::new(Location::of(1, 11), Location::of(1, 22)),
2235-
"safe_offset",
2236-
)]),
2237-
parameters: FunctionArguments::None,
2238-
args: FunctionArguments::List(FunctionArgumentList {
2239-
duplicate_treatment: None,
2240-
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value(
2241-
number("2").with_empty_span(),
2242-
)))],
2243-
clauses: vec![],
2244-
}),
2245-
filter: None,
2246-
null_treatment: None,
2247-
over: None,
2248-
within_group: vec![],
2249-
uses_odbc_syntax: false,
2250-
}.into()),
2232+
index: Expr::Function(
2233+
Function {
2234+
name: ObjectName::from(vec![Ident::with_span(
2235+
Span::new(Location::of(1, 11), Location::of(1, 22)),
2236+
"safe_offset",
2237+
)]),
2238+
parameters: FunctionArguments::None,
2239+
args: FunctionArguments::List(FunctionArgumentList {
2240+
duplicate_treatment: None,
2241+
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value(
2242+
number("2").with_empty_span(),
2243+
)))],
2244+
clauses: vec![],
2245+
}),
2246+
filter: None,
2247+
null_treatment: None,
2248+
over: None,
2249+
within_group: vec![],
2250+
uses_odbc_syntax: false,
2251+
}
2252+
.into(),
2253+
),
22512254
}),
22522255
AccessExpr::Dot(Expr::Identifier(Ident::with_span(
22532256
Span::new(Location::of(1, 24), Location::of(1, 25)),

tests/sqlparser_clickhouse.rs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -826,41 +826,45 @@ fn parse_create_table_with_variant_default_expressions() {
826826
data_type: DataType::Datetime(None),
827827
options: vec![ColumnOptionDef {
828828
name: None,
829-
option: ColumnOption::Materialized(Expr::Function(Box::new(Function {
830-
name: ObjectName::from(vec![Ident::new("now")]),
831-
uses_odbc_syntax: false,
832-
args: FunctionArguments::List(FunctionArgumentList {
833-
args: vec![],
834-
duplicate_treatment: None,
835-
clauses: vec![],
836-
}),
837-
parameters: FunctionArguments::None,
838-
null_treatment: None,
839-
filter: None,
840-
over: None,
841-
within_group: vec![],
842-
})))
829+
option: ColumnOption::Materialized(Expr::Function(Box::new(
830+
Function {
831+
name: ObjectName::from(vec![Ident::new("now")]),
832+
uses_odbc_syntax: false,
833+
args: FunctionArguments::List(FunctionArgumentList {
834+
args: vec![],
835+
duplicate_treatment: None,
836+
clauses: vec![],
837+
}),
838+
parameters: FunctionArguments::None,
839+
null_treatment: None,
840+
filter: None,
841+
over: None,
842+
within_group: vec![],
843+
}
844+
)))
843845
}],
844846
},
845847
ColumnDef {
846848
name: Ident::new("b"),
847849
data_type: DataType::Datetime(None),
848850
options: vec![ColumnOptionDef {
849851
name: None,
850-
option: ColumnOption::Ephemeral(Some(Expr::Function(Box::new(Function {
851-
name: ObjectName::from(vec![Ident::new("now")]),
852-
uses_odbc_syntax: false,
853-
args: FunctionArguments::List(FunctionArgumentList {
854-
args: vec![],
855-
duplicate_treatment: None,
856-
clauses: vec![],
857-
}),
858-
parameters: FunctionArguments::None,
859-
null_treatment: None,
860-
filter: None,
861-
over: None,
862-
within_group: vec![],
863-
}))))
852+
option: ColumnOption::Ephemeral(Some(Expr::Function(Box::new(
853+
Function {
854+
name: ObjectName::from(vec![Ident::new("now")]),
855+
uses_odbc_syntax: false,
856+
args: FunctionArguments::List(FunctionArgumentList {
857+
args: vec![],
858+
duplicate_treatment: None,
859+
clauses: vec![],
860+
}),
861+
parameters: FunctionArguments::None,
862+
null_treatment: None,
863+
filter: None,
864+
over: None,
865+
within_group: vec![],
866+
}
867+
))))
864868
}],
865869
},
866870
ColumnDef {

0 commit comments

Comments
 (0)