From 3374d16161973ad03678e9c149c8a9d54546a8b4 Mon Sep 17 00:00:00 2001 From: lmatz Date: Wed, 18 Dec 2024 02:21:25 +0800 Subject: [PATCH] fix style --- src/frontend/src/binder/query.rs | 2 +- src/frontend/src/planner/query.rs | 7 +------ src/sqlparser/tests/sqlparser_common.rs | 14 +++++++------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/frontend/src/binder/query.rs b/src/frontend/src/binder/query.rs index c70bd3a49c695..c7a1118662f6c 100644 --- a/src/frontend/src/binder/query.rs +++ b/src/frontend/src/binder/query.rs @@ -175,7 +175,7 @@ impl Binder { with_ties = fetch_with_ties; match quantity { Some(v) => Some(v), - None => Some(Expr::Value(Value::Number("1".to_string()))), + None => Some(Expr::Value(Value::Number("1".to_owned()))), } } (Some(limit), None) => Some(limit), diff --git a/src/frontend/src/planner/query.rs b/src/frontend/src/planner/query.rs index db116a0b07111..fc125574bc689 100644 --- a/src/frontend/src/planner/query.rs +++ b/src/frontend/src/planner/query.rs @@ -81,12 +81,7 @@ impl Planner { )) })?; let limit = match limit_cast_to_bigint.fold_const() { - Ok(datum) => match datum { - Some(datum) => datum.as_integral() as u64, - None => { - return Err(limit_err.into()); - } - }, + Ok(Some(datum)) => datum.as_integral() as u64, _ => return Err(limit_err.into()), }; diff --git a/src/sqlparser/tests/sqlparser_common.rs b/src/sqlparser/tests/sqlparser_common.rs index 8f0b308e4032d..9ce0b620bf963 100644 --- a/src/sqlparser/tests/sqlparser_common.rs +++ b/src/sqlparser/tests/sqlparser_common.rs @@ -207,7 +207,7 @@ fn parse_simple_select() { assert_eq!(3, select.projection.len()); let select = verified_query(sql); assert_eq!( - Some(Expr::Value(Value::Number("5".to_string()))), + Some(Expr::Value(Value::Number("5".to_owned()))), select.limit ); } @@ -216,10 +216,10 @@ fn parse_simple_select() { fn parse_limit_is_not_an_alias() { // In dialects supporting LIMIT it shouldn't be parsed as a table alias let ast = verified_query("SELECT id FROM customer LIMIT 1"); - assert_eq!(Some(Expr::Value(Value::Number("1".to_string()))), ast.limit); + assert_eq!(Some(Expr::Value(Value::Number("1".to_owned()))), ast.limit); let ast = verified_query("SELECT 1 LIMIT 5"); - assert_eq!(Some(Expr::Value(Value::Number("5".to_string()))), ast.limit); + assert_eq!(Some(Expr::Value(Value::Number("5".to_owned()))), ast.limit); } #[test] @@ -1072,7 +1072,7 @@ fn parse_select_order_by_limit() { select.order_by ); assert_eq!( - Some(Expr::Value(Value::Number("2".to_string()))), + Some(Expr::Value(Value::Number("2".to_owned()))), select.limit ); } @@ -1098,7 +1098,7 @@ fn parse_select_order_by_nulls_order() { select.order_by ); assert_eq!( - Some(Expr::Value(Value::Number("2".to_string()))), + Some(Expr::Value(Value::Number("2".to_owned()))), select.limit ); } @@ -3551,7 +3551,7 @@ fn parse_fetch() { let fetch_first_two_rows_only = Some(Fetch { with_ties: false, - quantity: Some(Expr::Value(Value::Number("2".to_string()))), + quantity: Some(Expr::Value(Value::Number("2".to_owned()))), }); let ast = verified_query("SELECT foo FROM bar FETCH FIRST 2 ROWS ONLY"); assert_eq!(ast.fetch, fetch_first_two_rows_only); @@ -3576,7 +3576,7 @@ fn parse_fetch() { ast.fetch, Some(Fetch { with_ties: true, - quantity: Some(Expr::Value(Value::Number("2".to_string()))), + quantity: Some(Expr::Value(Value::Number("2".to_owned()))), }) ); let ast = verified_query(