Skip to content

Commit d31efa6

Browse files
committed
fmt
1 parent ebb82e0 commit d31efa6

11 files changed

+931
-474
lines changed

tests/sqlparser_clickhouse.rs

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ fn parse_map_access_expr() {
5555
"indexOf",
5656
[
5757
Expr::Identifier(Ident::new("string_names")),
58-
Expr::Value((Value::SingleQuotedString("endpoint".to_string())).with_empty_span())
58+
Expr::Value(
59+
(Value::SingleQuotedString("endpoint".to_string()))
60+
.with_empty_span()
61+
)
5962
]
6063
),
6164
})],
@@ -71,7 +74,9 @@ fn parse_map_access_expr() {
7174
left: Box::new(BinaryOp {
7275
left: Box::new(Identifier(Ident::new("id"))),
7376
op: BinaryOperator::Eq,
74-
right: Box::new(Expr::Value((Value::SingleQuotedString("test".to_string())).with_empty_span())),
77+
right: Box::new(Expr::Value(
78+
(Value::SingleQuotedString("test".to_string())).with_empty_span()
79+
)),
7580
}),
7681
op: BinaryOperator::And,
7782
right: Box::new(BinaryOp {
@@ -82,13 +87,18 @@ fn parse_map_access_expr() {
8287
"indexOf",
8388
[
8489
Expr::Identifier(Ident::new("string_name")),
85-
Expr::Value((Value::SingleQuotedString("app".to_string())).with_empty_span())
90+
Expr::Value(
91+
(Value::SingleQuotedString("app".to_string()))
92+
.with_empty_span()
93+
)
8694
]
8795
),
8896
})],
8997
}),
9098
op: BinaryOperator::NotEq,
91-
right: Box::new(Expr::Value((Value::SingleQuotedString("foo".to_string())).with_empty_span())),
99+
right: Box::new(Expr::Value(
100+
(Value::SingleQuotedString("foo".to_string())).with_empty_span()
101+
)),
92102
}),
93103
}),
94104
group_by: GroupByExpr::Expressions(vec![], vec![]),
@@ -1014,17 +1024,15 @@ fn parse_select_parametric_function() {
10141024
assert_eq!(parameters.args.len(), 2);
10151025
assert_eq!(
10161026
parameters.args[0],
1017-
FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value((Value::Number(
1018-
"0.5".parse().unwrap(),
1019-
false
1020-
)).with_empty_span())))
1027+
FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value(
1028+
(Value::Number("0.5".parse().unwrap(), false)).with_empty_span()
1029+
)))
10211030
);
10221031
assert_eq!(
10231032
parameters.args[1],
1024-
FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value((Value::Number(
1025-
"0.6".parse().unwrap(),
1026-
false
1027-
)).with_empty_span())))
1033+
FunctionArg::Unnamed(FunctionArgExpr::Expr(Expr::Value(
1034+
(Value::Number("0.6".parse().unwrap(), false)).with_empty_span()
1035+
)))
10281036
);
10291037
}
10301038
_ => unreachable!(),
@@ -1103,7 +1111,10 @@ fn parse_select_order_by_with_fill_interpolate() {
11031111
},
11041112
select.order_by.expect("ORDER BY expected")
11051113
);
1106-
assert_eq!(Some(Expr::Value((number("2")).with_empty_span())), select.limit);
1114+
assert_eq!(
1115+
Some(Expr::Value((number("2")).with_empty_span())),
1116+
select.limit
1117+
);
11071118
}
11081119

11091120
#[test]
@@ -1236,7 +1247,9 @@ fn test_prewhere() {
12361247
Some(&BinaryOp {
12371248
left: Box::new(Identifier(Ident::new("x"))),
12381249
op: BinaryOperator::Eq,
1239-
right: Box::new(Expr::Value((Value::Number("1".parse().unwrap(), false)).with_empty_span())),
1250+
right: Box::new(Expr::Value(
1251+
(Value::Number("1".parse().unwrap(), false)).with_empty_span()
1252+
)),
12401253
})
12411254
);
12421255
let selection = query.as_ref().body.as_select().unwrap().selection.as_ref();
@@ -1245,7 +1258,9 @@ fn test_prewhere() {
12451258
Some(&BinaryOp {
12461259
left: Box::new(Identifier(Ident::new("y"))),
12471260
op: BinaryOperator::Eq,
1248-
right: Box::new(Expr::Value((Value::Number("2".parse().unwrap(), false)).with_empty_span())),
1261+
right: Box::new(Expr::Value(
1262+
(Value::Number("2".parse().unwrap(), false)).with_empty_span()
1263+
)),
12491264
})
12501265
);
12511266
}
@@ -1261,13 +1276,17 @@ fn test_prewhere() {
12611276
left: Box::new(BinaryOp {
12621277
left: Box::new(Identifier(Ident::new("x"))),
12631278
op: BinaryOperator::Eq,
1264-
right: Box::new(Expr::Value((Value::Number("1".parse().unwrap(), false)).with_empty_span())),
1279+
right: Box::new(Expr::Value(
1280+
(Value::Number("1".parse().unwrap(), false)).with_empty_span()
1281+
)),
12651282
}),
12661283
op: BinaryOperator::And,
12671284
right: Box::new(BinaryOp {
12681285
left: Box::new(Identifier(Ident::new("y"))),
12691286
op: BinaryOperator::Eq,
1270-
right: Box::new(Expr::Value((Value::Number("2".parse().unwrap(), false)).with_empty_span())),
1287+
right: Box::new(Expr::Value(
1288+
(Value::Number("2".parse().unwrap(), false)).with_empty_span()
1289+
)),
12711290
}),
12721291
})
12731292
);
@@ -1375,10 +1394,9 @@ fn parse_create_table_on_commit_and_as_query() {
13751394
assert_eq!(on_commit, Some(OnCommit::PreserveRows));
13761395
assert_eq!(
13771396
query.unwrap().body.as_select().unwrap().projection,
1378-
vec![UnnamedExpr(Expr::Value((Value::Number(
1379-
"1".parse().unwrap(),
1380-
false
1381-
)).with_empty_span()))]
1397+
vec![UnnamedExpr(Expr::Value(
1398+
(Value::Number("1".parse().unwrap(), false)).with_empty_span()
1399+
))]
13821400
);
13831401
}
13841402
_ => unreachable!(),
@@ -1391,9 +1409,9 @@ fn parse_freeze_and_unfreeze_partition() {
13911409
for operation_name in &["FREEZE", "UNFREEZE"] {
13921410
let sql = format!("ALTER TABLE t {operation_name} PARTITION '2024-08-14'");
13931411

1394-
let expected_partition = Partition::Expr(Expr::Value(Value::SingleQuotedString(
1395-
"2024-08-14".to_string(),
1396-
).with_empty_span()));
1412+
let expected_partition = Partition::Expr(Expr::Value(
1413+
Value::SingleQuotedString("2024-08-14".to_string()).with_empty_span(),
1414+
));
13971415
match clickhouse_and_generic().verified_stmt(&sql) {
13981416
Statement::AlterTable { operations, .. } => {
13991417
assert_eq!(operations.len(), 1);
@@ -1421,9 +1439,9 @@ fn parse_freeze_and_unfreeze_partition() {
14211439
match clickhouse_and_generic().verified_stmt(&sql) {
14221440
Statement::AlterTable { operations, .. } => {
14231441
assert_eq!(operations.len(), 1);
1424-
let expected_partition = Partition::Expr(Expr::Value(Value::SingleQuotedString(
1425-
"2024-08-14".to_string(),
1426-
).with_empty_span()));
1442+
let expected_partition = Partition::Expr(Expr::Value(
1443+
Value::SingleQuotedString("2024-08-14".to_string()).with_empty_span(),
1444+
));
14271445
let expected_operation = if operation_name == &"FREEZE" {
14281446
AlterTableOperation::FreezePartition {
14291447
partition: expected_partition,

0 commit comments

Comments
 (0)