Skip to content

Commit 6aaec4c

Browse files
committed
Cargo fmt
1 parent f8e9e18 commit 6aaec4c

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
@@ -2421,7 +2421,8 @@ impl<'a> Parser<'a> {
24212421
null_treatment: None,
24222422
over: None,
24232423
within_group: vec![],
2424-
}.into());
2424+
}
2425+
.into());
24252426
}
24262427

24272428
let mut args = self.parse_function_argument_list()?;
@@ -2489,7 +2490,8 @@ impl<'a> Parser<'a> {
24892490
filter,
24902491
over,
24912492
within_group,
2492-
}.into())
2493+
}
2494+
.into())
24932495
}
24942496

24952497
/// Optionally parses a null treatment clause.
@@ -2515,16 +2517,19 @@ impl<'a> Parser<'a> {
25152517
} else {
25162518
FunctionArguments::None
25172519
};
2518-
Ok(Expr::Function(Function {
2519-
name,
2520-
uses_odbc_syntax: false,
2521-
parameters: FunctionArguments::None,
2522-
args,
2523-
filter: None,
2524-
over: None,
2525-
null_treatment: None,
2526-
within_group: vec![],
2527-
}.into()))
2520+
Ok(Expr::Function(
2521+
Function {
2522+
name,
2523+
uses_odbc_syntax: false,
2524+
parameters: FunctionArguments::None,
2525+
args,
2526+
filter: None,
2527+
over: None,
2528+
null_treatment: None,
2529+
within_group: vec![],
2530+
}
2531+
.into(),
2532+
))
25282533
}
25292534

25302535
/// Parse window frame `UNITS` clause: `ROWS`, `RANGE`, or `GROUPS`.
@@ -13780,7 +13785,10 @@ impl<'a> Parser<'a> {
1378013785
let function_expr = self.parse_function(function_name)?;
1378113786
if let Expr::Function(function) = function_expr {
1378213787
let alias = self.parse_identifier_optional_alias()?;
13783-
pipe_operators.push(PipeOperator::Call { function: *function, alias });
13788+
pipe_operators.push(PipeOperator::Call {
13789+
function: *function,
13790+
alias,
13791+
});
1378413792
} else {
1378513793
return Err(ParserError::ParserError(
1378613794
"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
@@ -2219,25 +2219,28 @@ fn parse_map_access_expr() {
22192219
},
22202220
}),
22212221
AccessExpr::Subscript(Subscript::Index {
2222-
index: Expr::Function(Function {
2223-
name: ObjectName::from(vec![Ident::with_span(
2224-
Span::new(Location::of(1, 11), Location::of(1, 22)),
2225-
"safe_offset",
2226-
)]),
2227-
parameters: FunctionArguments::None,
2228-
args: FunctionArguments::List(FunctionArgumentList {
2229-
duplicate_treatment: None,
2230-
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value(
2231-
number("2").with_empty_span(),
2232-
)))],
2233-
clauses: vec![],
2234-
}),
2235-
filter: None,
2236-
null_treatment: None,
2237-
over: None,
2238-
within_group: vec![],
2239-
uses_odbc_syntax: false,
2240-
}.into()),
2222+
index: Expr::Function(
2223+
Function {
2224+
name: ObjectName::from(vec![Ident::with_span(
2225+
Span::new(Location::of(1, 11), Location::of(1, 22)),
2226+
"safe_offset",
2227+
)]),
2228+
parameters: FunctionArguments::None,
2229+
args: FunctionArguments::List(FunctionArgumentList {
2230+
duplicate_treatment: None,
2231+
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value(
2232+
number("2").with_empty_span(),
2233+
)))],
2234+
clauses: vec![],
2235+
}),
2236+
filter: None,
2237+
null_treatment: None,
2238+
over: None,
2239+
within_group: vec![],
2240+
uses_odbc_syntax: false,
2241+
}
2242+
.into(),
2243+
),
22412244
}),
22422245
AccessExpr::Dot(Expr::Identifier(Ident::with_span(
22432246
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)