diff --git a/benches/engine.rs b/benches/engine.rs index c612b65b3b3d8790690825fe39a5f4a647e3516b..b4ea51dc6b3d89c7419f77bc6f315811fd037d9c 100644 --- a/benches/engine.rs +++ b/benches/engine.rs @@ -451,6 +451,7 @@ impl Default for RouterRuntimeMock { impl RouterRuntimeMock { #[allow(dead_code)] + #[allow(clippy::missing_panics_doc)] #[must_use] pub fn new() -> Self { let cache: LRUCache<String, Plan> = LRUCache::new(DEFAULT_CAPACITY, None).unwrap(); diff --git a/benches/parse.rs b/benches/parse.rs index e4565b377be891d489d59ba43ed6f2eb3a70cd9a..82690391e67b186523cbd8b601494fbb3e82fbb1 100644 --- a/benches/parse.rs +++ b/benches/parse.rs @@ -6,6 +6,7 @@ use sbroad::executor::engine::cartridge::backend::sql::tree::{OrderedSyntaxNodes use sbroad::executor::Query; use sbroad::ir::value::Value; +#[allow(clippy::too_many_lines)] fn query1_sql() -> String { let sql = r#"SELECT * @@ -254,8 +255,8 @@ fn bench_query1(c: &mut Criterion) { let params = vec![Value::from(sys_from), Value::from(reestrid)]; sys_from += 1; reestrid += 1; - query1(&sql, params, &mut engine) - }) + query1(&sql, params, &mut engine); + }); }); } diff --git a/src/executor/bucket/tests.rs b/src/executor/bucket/tests.rs index 8a3b6029ee821363f0884d0dd20d998b3104e0a4..af7d43fd410ece1ae82e23c175e03170efa03641 100644 --- a/src/executor/bucket/tests.rs +++ b/src/executor/bucket/tests.rs @@ -9,6 +9,7 @@ use crate::ir::helpers::RepeatableState; use crate::ir::value::Value; #[test] +#[allow(clippy::similar_names)] fn simple_union_query() { let query = r#"SELECT * FROM ( SELECT * FROM "test_space" WHERE "sysFrom" > 0 @@ -33,6 +34,7 @@ fn simple_union_query() { } #[test] +#[allow(clippy::similar_names)] fn simple_disjunction_in_union_query() { let query = r#"SELECT * FROM ( SELECT * FROM "test_space" WHERE "sysFrom" > 0 @@ -89,6 +91,7 @@ fn complex_shard_key_union_query() { } #[test] +#[allow(clippy::similar_names)] fn union_complex_cond_query() { let query = r#"SELECT * FROM @@ -150,6 +153,7 @@ fn union_complex_cond_query() { } #[test] +#[allow(clippy::similar_names)] fn union_query_conjunction() { let query = r#"SELECT * FROM "test_space" WHERE "id" = 1 UNION ALL @@ -173,6 +177,7 @@ fn union_query_conjunction() { } #[test] +#[allow(clippy::similar_names)] fn simple_except_query() { let query = r#"SELECT * FROM ( SELECT * FROM "test_space" WHERE "sysFrom" > 0 diff --git a/src/executor/engine/cartridge/config/tests.rs b/src/executor/engine/cartridge/config/tests.rs index c6571fab204897418b278935e9f2ef7868c749e5..b3a288cf10fc06f792ef4cd49fc357d9f172716c 100644 --- a/src/executor/engine/cartridge/config/tests.rs +++ b/src/executor/engine/cartridge/config/tests.rs @@ -88,7 +88,7 @@ fn test_yaml_schema_parser() { let expected_keys = vec!["\"identification_number\"", "\"product_code\""]; let actual_keys = s.get_sharding_key_by_space("\"hash_testing\"").unwrap(); - assert_eq!(actual_keys, expected_keys) + assert_eq!(actual_keys, expected_keys); } #[test] @@ -154,7 +154,7 @@ fn test_getting_table_segment() { s.get_table_segment("invalid_table").unwrap_err(), QueryPlannerError::CustomError(r#"Space "INVALID_TABLE" not found"#.into()) ); - assert_eq!(s.get_table_segment("\"hash_testing\"").unwrap(), expected) + assert_eq!(s.get_table_segment("\"hash_testing\"").unwrap(), expected); } #[test] diff --git a/src/executor/engine/mock.rs b/src/executor/engine/mock.rs index aa7f621a0b7efe06fa7f24b0d627d31fecb68a96..dbbdc6e8b49cd5394c35b11b6505fb62fb3ba25d 100644 --- a/src/executor/engine/mock.rs +++ b/src/executor/engine/mock.rs @@ -283,13 +283,13 @@ impl Coordinator for RouterRuntimeMock { match buckets { Buckets::All => { let sql = plan.to_sql(&nodes, buckets)?; - result.extend(exec_on_all(&String::from(sql).as_str()))?; + result.extend(exec_on_all(String::from(sql).as_str()))?; } Buckets::Filtered(list) => { for bucket in list { let bucket_set: HashSet<u64, RepeatableState> = collection! { *bucket }; let sql = plan.to_sql(&nodes, &Buckets::Filtered(bucket_set))?; - let temp_result = exec_on_some(*bucket, &String::from(sql).as_str()); + let temp_result = exec_on_some(*bucket, String::from(sql).as_str()); result.extend(temp_result)?; } } @@ -329,6 +329,7 @@ impl Default for RouterRuntimeMock { impl RouterRuntimeMock { #[allow(dead_code)] + #[allow(clippy::missing_panics_doc)] #[must_use] pub fn new() -> Self { let cache: LRUCache<String, Plan> = LRUCache::new(DEFAULT_CAPACITY, None).unwrap(); diff --git a/src/executor/lru/tests.rs b/src/executor/lru/tests.rs index 9c4a4253ea243c5e51ad06df049e9a1510956465..c79d6d472b176ce2cc7b387b39ec52a3903a2dd6 100644 --- a/src/executor/lru/tests.rs +++ b/src/executor/lru/tests.rs @@ -26,10 +26,10 @@ fn lru3() { let evict_fn = Box::new(|value: &mut String| { let value_old = value.clone(); value.push_str("_old"); - return Err(QueryPlannerError::CustomError(format!( + Err(QueryPlannerError::CustomError(format!( "changed {} to {} during cache eviction", value_old, value - ))); + ))) }); let mut cache: LRUCache<usize, String> = LRUCache::new(1, Some(evict_fn)).unwrap(); cache.put(1, "one".to_string()).unwrap(); diff --git a/src/executor/tests/between.rs b/src/executor/tests/between.rs index 390e81b6b4ee797b30ff605b7da4dfe844d4c967..d87fe227e70a6bf54137b490660dceb0d253fbf7 100644 --- a/src/executor/tests/between.rs +++ b/src/executor/tests/between.rs @@ -27,7 +27,7 @@ fn between1_test() { let plan = query.exec_plan.get_ir_plan(); // Validate the motion type. - let motion_id = *get_motion_id(&plan, 0, 0).unwrap(); + let motion_id = *get_motion_id(plan, 0, 0).unwrap(); assert_eq!(&MotionPolicy::Full, get_motion_policy(plan, motion_id)); // Mock a virtual table. @@ -52,7 +52,7 @@ fn between1_test() { // Validate the result. let mut expected = ProducerResult::new(); expected.rows.extend(vec![vec![ - Value::String(format!("Execute query on all buckets")), + Value::String("Execute query on all buckets".to_string()), Value::String(String::from(PatternWithParams::new( format!( "{} {} {}", @@ -118,7 +118,7 @@ fn between2_test() { // Validate the result. let mut expected = ProducerResult::new(); expected.rows.extend(vec![vec![ - Value::String(format!("Execute query on all buckets")), + Value::String("Execute query on all buckets".to_string()), Value::String(String::from(PatternWithParams::new( format!( "{} {} {}", diff --git a/src/executor/tests/bucket_id.rs b/src/executor/tests/bucket_id.rs index 91e0e91bef266f9f207898668d710b213c85377b..767db6f986b7fea458249154fbed472088b8da4b 100644 --- a/src/executor/tests/bucket_id.rs +++ b/src/executor/tests/bucket_id.rs @@ -22,12 +22,9 @@ fn bucket1_test() { let mut expected = ProducerResult::new(); expected.rows.push(vec![ - Value::String(format!("Execute query on all buckets")), + Value::String("Execute query on all buckets".to_string()), Value::String(String::from(PatternWithParams::new( - format!( - "{}", - r#"SELECT "t1"."a", "t1"."b", "t1"."bucket_id" FROM "t1""#, - ), + r#"SELECT "t1"."a", "t1"."b", "t1"."bucket_id" FROM "t1""#.to_string(), vec![], ))), ]); diff --git a/src/executor/tests/not_eq.rs b/src/executor/tests/not_eq.rs index 79e478a4284e3a0c1220f99268ddb9531554e3f2..87cd5d962bee56986ab2045209b1edab5cbdc987 100644 --- a/src/executor/tests/not_eq.rs +++ b/src/executor/tests/not_eq.rs @@ -36,7 +36,7 @@ fn not_eq1_test() { // Validate the result. let mut expected = ProducerResult::new(); expected.rows.extend(vec![vec![ - Value::String(format!("Execute query on all buckets")), + Value::String("Execute query on all buckets".to_string()), Value::String(String::from(PatternWithParams::new( format!( "{} {}", @@ -65,7 +65,7 @@ fn not_eq2_test() { let plan = query.exec_plan.get_ir_plan(); // Validate the motion type. - let motion_id = *get_motion_id(&plan, 0, 0).unwrap(); + let motion_id = *get_motion_id(plan, 0, 0).unwrap(); assert_eq!(&MotionPolicy::Full, get_motion_policy(plan, motion_id)); assert_eq!(true, get_motion_id(plan, 0, 1).is_none()); @@ -91,7 +91,7 @@ fn not_eq2_test() { // Validate the result. let mut expected = ProducerResult::new(); expected.rows.extend(vec![vec![ - Value::String(format!("Execute query on all buckets")), + Value::String("Execute query on all buckets".to_string()), Value::String(String::from(PatternWithParams::new( format!( "{} {}", diff --git a/src/executor/tests/not_in.rs b/src/executor/tests/not_in.rs index 9551d331e5adb813fe6605b1c1d4be17c4e6fcfc..3c2591187345b8fac9f1c463002e36c72f312304 100644 --- a/src/executor/tests/not_in.rs +++ b/src/executor/tests/not_in.rs @@ -27,7 +27,7 @@ fn not_in1_test() { let plan = query.exec_plan.get_ir_plan(); // Validate the motion type. - let motion_id = *get_motion_id(&plan, 0, 0).unwrap(); + let motion_id = *get_motion_id(plan, 0, 0).unwrap(); assert_eq!(&MotionPolicy::Full, get_motion_policy(plan, motion_id)); assert_eq!(true, get_motion_id(plan, 0, 1).is_none()); @@ -53,7 +53,7 @@ fn not_in1_test() { // Validate the result. let mut expected = ProducerResult::new(); expected.rows.extend(vec![vec![ - Value::String(format!("Execute query on all buckets")), + Value::String("Execute query on all buckets".to_string()), Value::String(String::from(PatternWithParams::new( format!( "{} {}", diff --git a/src/executor/vtable/tests.rs b/src/executor/vtable/tests.rs index 44543770478dda0214328ca6ccffc8022c638821..4c78ff0ccf1a76a737593d0c9fdd4a06766c279b 100644 --- a/src/executor/vtable/tests.rs +++ b/src/executor/vtable/tests.rs @@ -27,5 +27,5 @@ fn virtual_table() { index: HashMap::with_hasher(RandomState::new()), }; - assert_eq!(expected, vtable) + assert_eq!(expected, vtable); } diff --git a/src/frontend/sql/ir/tests.rs b/src/frontend/sql/ir/tests.rs index ebce591a64e44ca7e150c8897cac5365756a2810..e907af5f711a86e4f73d21619e4706dc13ccaf5e 100644 --- a/src/frontend/sql/ir/tests.rs +++ b/src/frontend/sql/ir/tests.rs @@ -15,7 +15,7 @@ fn front_sql1() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -33,7 +33,7 @@ fn front_sql2() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -64,7 +64,7 @@ fn front_sql3() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -99,7 +99,7 @@ fn front_sql4() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -123,7 +123,7 @@ motion [policy: full, generation: none] "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -149,7 +149,7 @@ fn front_sql6() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -166,7 +166,7 @@ fn front_sql8() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -218,7 +218,7 @@ fn front_sql9() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -235,7 +235,7 @@ fn front_sql10() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -252,7 +252,7 @@ fn front_sql11() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -269,7 +269,7 @@ fn front_sql14() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } // check cyrillic strings support @@ -287,7 +287,7 @@ fn front_sql16() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -304,7 +304,7 @@ fn front_sql17() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -321,7 +321,7 @@ fn front_sql18() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] @@ -338,7 +338,7 @@ fn front_sql19() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[cfg(test)] diff --git a/src/frontend/sql/ir/tests/params.rs b/src/frontend/sql/ir/tests/params.rs index b35e2924c4865d09442d0b442b23ef88c80fb8fa..7e51538b045bbae8ecd949b1ffde4dbe2344b282 100644 --- a/src/frontend/sql/ir/tests/params.rs +++ b/src/frontend/sql/ir/tests/params.rs @@ -15,7 +15,7 @@ fn front_params1() { "#, ); - assert_eq!(expected_explain, plan.as_explain().unwrap()) + assert_eq!(expected_explain, plan.as_explain().unwrap()); } #[test] diff --git a/src/ir/distribution/tests.rs b/src/ir/distribution/tests.rs index 90320fd03d3e450360f8a67f04c0d288980d16e0..e77fc46e6a31b25ae63f0e09accd076909d3703b 100644 --- a/src/ir/distribution/tests.rs +++ b/src/ir/distribution/tests.rs @@ -1,6 +1,6 @@ use super::*; -use crate::ir::relation::*; -use crate::ir::*; +use crate::ir::relation::{Column, ColumnRole, Table, Type}; +use crate::ir::{Node, Plan}; use pretty_assertions::assert_eq; use std::fs; use std::path::Path; diff --git a/src/ir/explain/tests.rs b/src/ir/explain/tests.rs index d8a564bc488c913b380cf659629114e594bcddac..0eda0516bfb9ac9e200ac326429f7af0624a1013 100644 --- a/src/ir/explain/tests.rs +++ b/src/ir/explain/tests.rs @@ -20,7 +20,7 @@ fn simple_query_without_cond_plan() { "#, ); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -40,7 +40,7 @@ fn simple_query_with_cond_plan() { "#, ); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -62,7 +62,7 @@ fn union_query_plan() { r#" projection ("t2"."identification_number" -> "identification_number", "t2"."product_code" -> "product_code")"#, r#" scan "hash_testing_hist" -> "t2""#, ); - assert_eq!(expected, explain_tree.to_string()) + assert_eq!(expected, explain_tree.to_string()); } #[test] @@ -92,7 +92,7 @@ WHERE "id" = 1"#; scan "test_space_hist" "#); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -141,7 +141,7 @@ scan scan "test_space_hist" "#); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -163,7 +163,7 @@ fn explain_except1() { r#" projection ("hash_testing_hist"."identification_number" -> "identification_number")"#, r#" scan "hash_testing_hist""#, ); - assert_eq!(expected, explain_tree.to_string()) + assert_eq!(expected, explain_tree.to_string()); } #[test] @@ -219,7 +219,7 @@ motion [policy: segment([ref("identification_number")]), generation: none] scan "hash_testing" "#); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -248,7 +248,7 @@ WHERE "t2"."product_code" = '123'"#; scan "hash_testing" "#); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -280,7 +280,7 @@ motion [policy: segment([ref("identification_number")]), generation: none] scan "hash_testing" "#); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -300,7 +300,7 @@ fn unary_condition_plan() { "#, ); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -321,7 +321,7 @@ fn insert_plan() { "#, ); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -344,7 +344,7 @@ fn multiply_insert_plan() { "#, ); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -366,7 +366,7 @@ SELECT "identification_number", "product_code" FROM "hash_testing""#; "#, ); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } #[test] @@ -387,5 +387,5 @@ fn select_value_plan() { "#, ); - assert_eq!(actual_explain, explain_tree.to_string()) + assert_eq!(actual_explain, explain_tree.to_string()); } diff --git a/src/ir/expression/tests.rs b/src/ir/expression/tests.rs index 362c90c2e292a407e5bcc8dbb228e503359c4f35..7af4fb63dd4ca3918f10cd1a2b01312e5c408abd 100644 --- a/src/ir/expression/tests.rs +++ b/src/ir/expression/tests.rs @@ -1,8 +1,8 @@ use pretty_assertions::assert_eq; -use crate::ir::relation::*; -use crate::ir::value::*; -use crate::ir::*; +use crate::ir::relation::{Column, ColumnRole, Table, Type}; +use crate::ir::value::Value; +use crate::ir::{Plan, QueryPlannerError}; #[test] fn row_duplicate_column_names() { diff --git a/src/ir/operator/tests.rs b/src/ir/operator/tests.rs index 0982b1a502a818246552e3ffaa6ceeff9dcb43a2..df202e1e7c14282971f7b92bcbe2a9702591247f 100644 --- a/src/ir/operator/tests.rs +++ b/src/ir/operator/tests.rs @@ -5,10 +5,10 @@ use pretty_assertions::assert_eq; use crate::collection; use crate::errors::QueryPlannerError; -use crate::ir::distribution::*; -use crate::ir::relation::*; -use crate::ir::value::*; -use crate::ir::*; +use crate::ir::distribution::{Distribution, Key}; +use crate::ir::relation::{Column, ColumnRole, Table, Type}; +use crate::ir::value::Value; +use crate::ir::{Node, Plan}; use super::*; @@ -296,6 +296,7 @@ fn sub_query_serialize() { } #[test] +#[allow(clippy::similar_names)] fn selection_with_sub_query() { // t1(a int) key [a] // t2(b int) key [b] diff --git a/src/ir/relation/tests.rs b/src/ir/relation/tests.rs index 0b899aee8b8776cd0ede8078d2f221921407f856..96bbc00fcc5142fd265e770e2d9897e378a1fec8 100644 --- a/src/ir/relation/tests.rs +++ b/src/ir/relation/tests.rs @@ -241,7 +241,7 @@ fn column_msgpack_serialize() { 0x70, 0x65, 0xA6, 0x6E, 0x75, 0x6D, 0x62, 0x65, 0x72, ], rmp_serde::to_vec(&c).unwrap() - ) + ); } #[test] diff --git a/src/ir/tests.rs b/src/ir/tests.rs index 12fdc554774e252c4beeae0e7ada782b30263b98..d88ab462841159d689071a43b43e88668856e37f 100644 --- a/src/ir/tests.rs +++ b/src/ir/tests.rs @@ -1,5 +1,5 @@ use super::*; -use crate::ir::relation::*; +use crate::ir::relation::{Column, ColumnRole, Table, Type}; use pretty_assertions::assert_eq; use std::fs; use std::path::Path; diff --git a/src/ir/transformation/equality_propagation/tests.rs b/src/ir/transformation/equality_propagation/tests.rs index 6f9a0ed617b034be34dd2194f3235fccd7af946c..31d41f2b0efbfa29f5a7d03e2a2f618c61e89b3e 100644 --- a/src/ir/transformation/equality_propagation/tests.rs +++ b/src/ir/transformation/equality_propagation/tests.rs @@ -37,10 +37,7 @@ fn equality_propagation2() { WHERE "a" = NULL AND "b" = NULL"#; let expected = PatternWithParams::new( - format!( - "{}", - r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") = (?) and ("t"."b") = (?)"#, - ), + r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") = (?) and ("t"."b") = (?)"#.to_string(), vec![Value::Null, Value::Null], ); diff --git a/src/ir/transformation/helpers.rs b/src/ir/transformation/helpers.rs index b4d009282fb66ce0534c43473efbe1e3e0d05a3b..d99f3f0799916be17de443e68ddd58bbd8903311 100644 --- a/src/ir/transformation/helpers.rs +++ b/src/ir/transformation/helpers.rs @@ -11,7 +11,11 @@ use crate::ir::value::Value; use crate::ir::Plan; /// Compiles an SQL query to optimized IR plan. -#[allow(dead_code)] +/// +/// # Panics +/// if query is not correct +#[must_use] +#[allow(clippy::missing_panics_doc)] pub fn sql_to_optimized_ir(query: &str, params: Vec<Value>) -> Plan { let mut plan = sql_to_ir(query, params); plan.optimize().unwrap(); @@ -19,7 +23,10 @@ pub fn sql_to_optimized_ir(query: &str, params: Vec<Value>) -> Plan { } /// Compiles an SQL query to IR plan. -#[allow(dead_code)] +/// +/// # Panics +/// if query is not correct +#[must_use] pub fn sql_to_ir(query: &str, params: Vec<Value>) -> Plan { let metadata = &RouterConfigurationMock::new(); let ast = AbstractSyntaxTree::new(query).unwrap(); @@ -29,6 +36,9 @@ pub fn sql_to_ir(query: &str, params: Vec<Value>) -> Plan { } /// Compiles and transforms an SQL query to a new parameterized SQL. +/// +/// # Panics +/// if query is not correct #[allow(dead_code)] pub fn sql_to_sql( query: &str, diff --git a/src/ir/transformation/merge_tuples/tests.rs b/src/ir/transformation/merge_tuples/tests.rs index 4408f3ce2d02d0085cd3e126195f6b6ec4dc1ff7..44f341b04733c0d5ee79d91cb02f325d0216e8ed 100644 --- a/src/ir/transformation/merge_tuples/tests.rs +++ b/src/ir/transformation/merge_tuples/tests.rs @@ -57,7 +57,7 @@ fn merge_tuples2() { fn merge_tuples3() { let input = r#"SELECT "a" FROM "t" WHERE true"#; let expected = PatternWithParams::new( - format!("{}", r#"SELECT "t"."a" FROM "t" WHERE ?"#), + r#"SELECT "t"."a" FROM "t" WHERE ?"#.to_string(), vec![Value::Boolean(true)], ); diff --git a/src/ir/transformation/redistribution/tests.rs b/src/ir/transformation/redistribution/tests.rs index c04ac6a36bb6ed0de72aa672f008a94fde3bfd33..c9941e1e03420c647830c904472c485fcbd7791a 100644 --- a/src/ir/transformation/redistribution/tests.rs +++ b/src/ir/transformation/redistribution/tests.rs @@ -1,9 +1,9 @@ use super::*; use crate::collection; use crate::errors::QueryPlannerError; -use crate::ir::distribution::*; +use crate::ir::distribution::{Distribution, Key}; use crate::ir::operator::Relational; -use crate::ir::relation::*; +use crate::ir::relation::{Column, ColumnRole, Table, Type}; use crate::ir::transformation::helpers::sql_to_ir; use crate::ir::Plan; use ahash::RandomState; @@ -12,6 +12,7 @@ use std::fs; use std::path::Path; #[test] +#[allow(clippy::similar_names)] fn segment_motion_for_sub_query() { // t1(a int) key [a] // t2(a int, b int) key [a] @@ -143,6 +144,7 @@ fn full_motion_less_for_sub_query() { } #[test] +#[allow(clippy::similar_names)] fn full_motion_non_segment_outer_for_sub_query() { // t1(a int, b int) key [a] // t2(a int) key [a] @@ -201,6 +203,7 @@ fn full_motion_non_segment_outer_for_sub_query() { } #[test] +#[allow(clippy::similar_names)] fn local_sub_query() { // t1(a int) key [a] // t2(a int, b int) key [a] @@ -389,9 +392,9 @@ fn join_inner_eq_non_match_keys() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -435,9 +438,9 @@ fn join_inner_sq_less_for_keys() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -460,9 +463,9 @@ fn join_inner_sq_eq_no_keys() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -485,9 +488,9 @@ fn join_inner_sq_eq_no_outer_keys() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -511,9 +514,9 @@ fn inner_join_full_policy_sq_in_filter() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -569,9 +572,9 @@ fn inner_join_full_policy_sq_with_union_all_in_filter() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -617,9 +620,9 @@ fn join_inner_or_local_full_policies() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -658,9 +661,9 @@ fn join1() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -702,9 +705,9 @@ fn redistribution1() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -734,9 +737,9 @@ fn redistribution2() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -766,9 +769,9 @@ fn redistribution3() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -796,9 +799,9 @@ fn redistribution4() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -826,9 +829,9 @@ fn redistribution5() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -856,9 +859,9 @@ fn redistribution6() { .slices .as_ref() .unwrap() - .get(0) + .first() .unwrap() - .get(0) + .first() .unwrap(); let motion = plan.get_relation_node(motion_id).unwrap(); if let Relational::Motion { policy, .. } = motion { @@ -874,6 +877,10 @@ fn redistribution6() { } /// Helper function to extract a motion id from a plan. +/// +/// # Panics +/// Motion node does not found +#[must_use] pub fn get_motion_id(plan: &Plan, slice_id: usize, motion_idx: usize) -> Option<&usize> { let slice = plan.slices.as_ref().unwrap().get(slice_id).unwrap(); slice.get(motion_idx) diff --git a/src/ir/transformation/redistribution/tests/between.rs b/src/ir/transformation/redistribution/tests/between.rs index 4cd67d0bdfdf707cdc4520907cc98c1e235a9fcc..e901cff27131f603a759ff1e857039fc85683e05 100644 --- a/src/ir/transformation/redistribution/tests/between.rs +++ b/src/ir/transformation/redistribution/tests/between.rs @@ -1,10 +1,11 @@ use crate::ir::operator::Relational; use crate::ir::transformation::helpers::sql_to_ir; use crate::ir::transformation::redistribution::tests::get_motion_id; -use crate::ir::transformation::redistribution::*; +use crate::ir::transformation::redistribution::MotionPolicy; use pretty_assertions::assert_eq; #[test] +#[allow(clippy::similar_names)] fn between1() { let query = r#"SELECT "identification_number" FROM "hash_testing" AS "t" WHERE (SELECT "identification_number" FROM "hash_testing_hist" AS "h" diff --git a/src/ir/transformation/redistribution/tests/except.rs b/src/ir/transformation/redistribution/tests/except.rs index d092fc260257315ff9e10165900e43c5f73c64e2..3c8cbb8c0e9e43796b238fe502e0b0c8ee381bf2 100644 --- a/src/ir/transformation/redistribution/tests/except.rs +++ b/src/ir/transformation/redistribution/tests/except.rs @@ -1,7 +1,7 @@ use crate::ir::operator::Relational; use crate::ir::transformation::helpers::sql_to_ir; use crate::ir::transformation::redistribution::tests::get_motion_id; -use crate::ir::transformation::redistribution::*; +use crate::ir::transformation::redistribution::{Key, MotionPolicy}; use pretty_assertions::assert_eq; #[test] diff --git a/src/ir/transformation/redistribution/tests/not_in.rs b/src/ir/transformation/redistribution/tests/not_in.rs index 1be1e1cff590688fcf678741757199aba21b64f9..ec8ee3a79aa6013216ca46b6c84ced944e828957 100644 --- a/src/ir/transformation/redistribution/tests/not_in.rs +++ b/src/ir/transformation/redistribution/tests/not_in.rs @@ -1,7 +1,7 @@ use crate::ir::operator::Relational; use crate::ir::transformation::helpers::sql_to_ir; use crate::ir::transformation::redistribution::tests::get_motion_id; -use crate::ir::transformation::redistribution::*; +use crate::ir::transformation::redistribution::{Key, MotionPolicy}; use pretty_assertions::assert_eq; #[test] diff --git a/src/ir/transformation/split_columns/tests.rs b/src/ir/transformation/split_columns/tests.rs index 98d0f6c741157fdc440034cf42403b5b2f953a8a..6ea55c0aa588b2c5edbe2cf14e7568f298fd3748 100644 --- a/src/ir/transformation/split_columns/tests.rs +++ b/src/ir/transformation/split_columns/tests.rs @@ -15,10 +15,7 @@ fn split_columns(plan: &mut Plan) { fn split_columns1() { let input = r#"SELECT "a" FROM "t" WHERE ("a", 2) = (1, "b")"#; let expected = PatternWithParams::new( - format!( - "{}", - r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") = (?) and (?) = ("t"."b")"#, - ), + r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") = (?) and (?) = ("t"."b")"#.to_string(), vec![Value::from(1_u64), Value::from(2_u64)], ); @@ -29,7 +26,7 @@ fn split_columns1() { fn split_columns2() { let input = r#"SELECT "a" FROM "t" WHERE "a" = 1"#; let expected = PatternWithParams::new( - format!("{}", r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") = (?)"#,), + r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") = (?)"#.to_string(), vec![Value::from(1_u64)], ); @@ -60,7 +57,7 @@ fn split_columns3() { fn split_columns4() { let input = r#"SELECT "a" FROM "t" WHERE "a" in (1, 2)"#; let expected = PatternWithParams::new( - format!("{}", r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") in (?, ?)"#,), + r#"SELECT "t"."a" FROM "t" WHERE ("t"."a") in (?, ?)"#.to_string(), vec![Value::from(1_u64), Value::from(2_u64)], ); diff --git a/src/ir/tree/tests.rs b/src/ir/tree/tests.rs index 1f481b9736c7220481ed81ee25c5d7d21e40c825..f8ea53c900eb3d9e469a30cf7d264f660dd851c7 100644 --- a/src/ir/tree/tests.rs +++ b/src/ir/tree/tests.rs @@ -1,7 +1,7 @@ -use crate::ir::operator::*; -use crate::ir::relation::*; -use crate::ir::value::*; -use crate::ir::*; +use crate::ir::operator::Bool; +use crate::ir::relation::{Column, ColumnRole, Table, Type}; +use crate::ir::value::Value; +use crate::ir::{Expression, Plan}; use pretty_assertions::assert_eq; use traversal::{Bft, DftPost, DftPre}; @@ -41,6 +41,7 @@ fn expression_bft() { } #[test] +#[allow(clippy::similar_names)] fn and_chain_pre() { // (((b1 or b2) and b3) and b4) and (b5 = (b6 = b7)) @@ -247,7 +248,7 @@ fn subtree_dfs_post() { .unwrap() .clone_row_list() .unwrap(); - let alias_id = row_children.get(0).unwrap(); + let alias_id = row_children.first().unwrap(); let c_ref_id = if let Expression::Alias { child, .. } = plan.get_expression_node(*alias_id).unwrap() { child diff --git a/src/ir/value/double/tests.rs b/src/ir/value/double/tests.rs index d9bd03bb27c9663812e7103541524af15bc81866..f616b90d15a062e6125891d889c1c824621f5459 100644 --- a/src/ir/value/double/tests.rs +++ b/src/ir/value/double/tests.rs @@ -2,31 +2,32 @@ use super::*; use pretty_assertions::assert_eq; #[test] +#[allow(clippy::excessive_precision)] fn equivalence() { // Yes, this is correct (checked on Tarantool). assert_eq!( - Double::from(0.9999999999999997e-308_f64), + Double::from(0.999_999_999_999_999_7e-308_f64), Double::from(1e-308_f64) ); assert_ne!( - Double::from(0.9999999999999996e-308_f64), - Double::from(0.9999999999999997e-308_f64) + Double::from(0.999_999_999_999_999_6e-308_f64), + Double::from(0.999_999_999_999_999_7e-308_f64) ); // Yes, this is correct (checked on Tarantool). assert_eq!( - Double::from(0.9999999999999995e-308_f64), - Double::from(0.9999999999999996e-308_f64) + Double::from(0.999_999_999_999_999_5e-308_f64), + Double::from(0.999_999_999_999_999_6e-308_f64) ); assert_eq!( - Double::from(0.9999999999999995e-308_f64), + Double::from(0.999_999_999_999_999_5e-308_f64), "0.9999999999999995e-308".parse::<Double>().unwrap() ); assert_eq!( - Double::from(9223372036854775807_f64), + Double::from(9_223_372_036_854_775_807_f64), "9223372036854775807".parse::<Double>().unwrap() ); assert_eq!( - Double::from(18446744073709551615_u64), + Double::from(18_446_744_073_709_551_615_u64), "18446744073709551615".parse::<Double>().unwrap() ); assert_eq!( diff --git a/src/ir/value/tests.rs b/src/ir/value/tests.rs index ee762d03a1f402cd2a2f813ab2be2bf2af9c812f..b2d7cd9d5e0373aaa258a1cf5a5f4787b4f5461d 100644 --- a/src/ir/value/tests.rs +++ b/src/ir/value/tests.rs @@ -25,7 +25,7 @@ fn decimal() { ); assert_eq!( Value::Decimal(Decimal::from_str("9223372036854775807").unwrap()), - Value::from(Decimal::from(9223372036854775807_u64)) + Value::from(Decimal::from(9_223_372_036_854_775_807_u64)) ); assert_ne!( Value::Decimal(decimal!(1)), @@ -34,19 +34,20 @@ fn decimal() { } #[test] +#[allow(clippy::excessive_precision)] fn double() { assert_eq!( Value::Double(0.0_f64.into()), Value::from(Double::from(0.0000_f64)) ); assert_eq!( - Value::Double(0.9999999999999997e-308_f64.into()), + Value::Double(0.999_999_999_999_999_7e-308_f64.into()), Value::from(Double::from(1e-308_f64)) ); assert_eq!(Value::from(f64::NAN), Value::Null); assert_ne!( - Value::Double(Double::from(0.9999999999999996e-308_f64)), - Value::from(Double::from(0.9999999999999997e-308_f64)) + Value::Double(Double::from(0.999_999_999_999_999_6e-308_f64)), + Value::from(Double::from(0.999_999_999_999_999_7e-308_f64)) ); } @@ -54,16 +55,16 @@ fn double() { fn integer() { assert_eq!(Value::Integer(0), Value::from(0_i64)); assert_eq!( - Value::Integer(9223372036854775807_i64), - Value::from(9223372036854775807_i64) + Value::Integer(9_223_372_036_854_775_807_i64), + Value::from(9_223_372_036_854_775_807_i64) ); assert_eq!( - Value::Integer(-9223372036854775807_i64), - Value::from(-9223372036854775807_i64) + Value::Integer(-9_223_372_036_854_775_807_i64), + Value::from(-9_223_372_036_854_775_807_i64) ); assert_ne!( - Value::Integer(9223372036854775807_i64), - Value::from(-9223372036854775807_i64) + Value::Integer(9_223_372_036_854_775_807_i64), + Value::from(-9_223_372_036_854_775_807_i64) ); } @@ -86,12 +87,13 @@ fn unsigned() { assert_eq!(Value::Unsigned(0), Value::from(0_u64)); assert_eq!( Value::Unsigned(u64::MAX), - Value::from(18446744073709551615_u64) + Value::from(18_446_744_073_709_551_615_u64) ); assert_ne!(Value::Unsigned(0_u64), Value::from(1_u64)); } #[test] +#[allow(clippy::too_many_lines)] fn equivalence() { // Boolean assert_eq!(