Apache DataFusion SQL Query Engine
minor: remove redundant `unwrap()` (#4463)
jakevinc806cd1a0f14
diff --git a/datafusion-examples/examples/custom_datasource.rs b/datafusion-examples/examples/custom_datasource.rsindex 563f2cd3d3..3be17d9500 100644--- a/datafusion-examples/examples/custom_datasource.rs+++ b/datafusion-examples/examples/custom_datasource.rs@@ -66,10 +66,8 @@ async fn search_accounts(provider_as_source(Arc::new(db)),None,vec![],- )- .unwrap()- .build()- .unwrap();+ )?+ .build()?;let mut dataframe = DataFrame::new(ctx.state, &logical_plan).select_columns(&["id", "bank_account"])?;diff --git a/datafusion/core/src/dataframe.rs b/datafusion/core/src/dataframe.rsindex 578afc9ee3..495536fcdf 100644--- a/datafusion/core/src/dataframe.rs+++ b/datafusion/core/src/dataframe.rs@@ -915,15 +915,14 @@ mod tests {async fn select_with_periods() -> Result<()> {// define data with a column name that has a "." in it:let array: Int32Array = [1, 10].into_iter().collect();- let batch =- RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)]).unwrap();+ let batch = RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)])?;let ctx = SessionContext::new();- ctx.register_batch("t", batch).unwrap();+ ctx.register_batch("t", batch)?;- let df = ctx.table("t").unwrap().select_columns(&["f.c1"]).unwrap();+ let df = ctx.table("t")?.select_columns(&["f.c1"])?;- let df_results = df.collect().await.unwrap();+ let df_results = df.collect().await?;assert_batches_sorted_eq!(vec!["+------+", "| f.c1 |", "+------+", "| 1 |", "| 10 |", "+------+",],@@ -1387,7 +1386,7 @@ mod tests {let plan = df.explain(false, false)?.collect().await?;// Filters all the way to Parquet- let formatted = pretty::pretty_format_batches(&plan).unwrap().to_string();+ let formatted = pretty::pretty_format_batches(&plan)?.to_string();assert!(formatted.contains("FilterExec: id@0 = 1"));Ok(())@@ -1446,8 +1445,8 @@ mod tests {GROUP BYcolumn_1"#;- let df = ctx.sql(sql).await.unwrap();- df.show_limit(10).await.unwrap();+ let df = ctx.sql(sql).await?;+ df.show_limit(10).await?;Ok(())}@@ -1456,20 +1455,17 @@ mod tests {async fn with_column_name() -> Result<()> {// define data with a column name that has a "." in it:let array: Int32Array = [1, 10].into_iter().collect();- let batch =- RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)]).unwrap();+ let batch = RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)])?;let ctx = SessionContext::new();- ctx.register_batch("t", batch).unwrap();+ ctx.register_batch("t", batch)?;let df = ctx- .table("t")- .unwrap()+ .table("t")?// try and create a column with a '.' in it- .with_column("f.c2", lit("hello"))- .unwrap();+ .with_column("f.c2", lit("hello"))?;- let df_results = df.collect().await.unwrap();+ let df_results = df.collect().await?;assert_batches_sorted_eq!(vec![@@ -1649,8 +1645,8 @@ mod tests {| JoinType::LeftSemi| JoinType::LeftAnti => {let left_exprs: Vec<Arc<dyn PhysicalExpr>> = vec![- Arc::new(Column::new_with_schema("c1", &join_schema).unwrap()),- Arc::new(Column::new_with_schema("c2", &join_schema).unwrap()),+ Arc::new(Column::new_with_schema("c1", &join_schema)?),+ Arc::new(Column::new_with_schema("c2", &join_schema)?),];assert_eq!(out_partitioning,@@ -1659,8 +1655,8 @@ mod tests {}JoinType::Right | JoinType::RightSemi | JoinType::RightAnti => {let right_exprs: Vec<Arc<dyn PhysicalExpr>> = vec![- Arc::new(Column::new_with_schema("c2_c1", &join_schema).unwrap()),- Arc::new(Column::new_with_schema("c2_c2", &join_schema).unwrap()),+ Arc::new(Column::new_with_schema("c2_c1", &join_schema)?),+ Arc::new(Column::new_with_schema("c2_c2", &join_schema)?),];assert_eq!(out_partitioning,diff --git a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rsindex 476f30689c..d2c57f3a79 100644--- a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs+++ b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs@@ -169,25 +169,23 @@ mod tests {.expect("building plan")}- fn assert_optimized_plan_eq(plan: &LogicalPlan, expected: &str) {+ fn assert_optimized_plan_eq(plan: &LogicalPlan, expected: &str) -> Result<()> {let rule = SimplifyExpressions::new();let optimized_plan = rule.optimize(plan, &mut OptimizerConfig::new()).expect("failed to optimize plan");let formatted_plan = format!("{:?}", optimized_plan);assert_eq!(formatted_plan, expected);+ Ok(())}#[test]- fn test_simplify_optimized_plan() {+ fn test_simplify_optimized_plan() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .project(vec![col("a")])- .unwrap()- .filter(and(col("b").gt(lit(1)), col("b").gt(lit(1))))- .unwrap()- .build()- .unwrap();+ .project(vec![col("a")])?+ .filter(and(col("b").gt(lit(1)), col("b").gt(lit(1))))?+ .build()?;assert_optimized_plan_eq(&plan,@@ -195,19 +193,16 @@ mod tests {Filter: test.b > Int32(1)\\n Projection: test.a\\n TableScan: test",- );+ )}#[test]- fn test_simplify_optimized_plan_with_or() {+ fn test_simplify_optimized_plan_with_or() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .project(vec![col("a")])- .unwrap()- .filter(or(col("b").gt(lit(1)), col("b").gt(lit(1))))- .unwrap()- .build()- .unwrap();+ .project(vec![col("a")])?+ .filter(or(col("b").gt(lit(1)), col("b").gt(lit(1))))?+ .build()?;assert_optimized_plan_eq(&plan,@@ -215,23 +210,20 @@ mod tests {Filter: test.b > Int32(1)\\n Projection: test.a\\n TableScan: test",- );+ )}#[test]- fn test_simplify_optimized_plan_with_composed_and() {+ fn test_simplify_optimized_plan_with_composed_and() -> Result<()> {let table_scan = test_table_scan();// ((c > 5) AND (d < 6)) AND (c > 5) --> (c > 5) AND (d < 6)let plan = LogicalPlanBuilder::from(table_scan)- .project(vec![col("a"), col("b")])- .unwrap()+ .project(vec![col("a"), col("b")])?.filter(and(and(col("a").gt(lit(5)), col("b").lt(lit(6))),col("a").gt(lit(5)),- ))- .unwrap()- .build()- .unwrap();+ ))?+ .build()?;assert_optimized_plan_eq(&plan,@@ -239,21 +231,17 @@ mod tests {Filter: test.a > Int32(5) AND test.b < Int32(6)\\n Projection: test.a, test.b\\n TableScan: test",- );+ )}#[test]- fn test_simplity_optimized_plan_eq_expr() {+ fn test_simplify_optimized_plan_eq_expr() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("b").eq(lit(true)))- .unwrap()- .filter(col("c").eq(lit(false)))- .unwrap()- .project(vec![col("a")])- .unwrap()- .build()- .unwrap();+ .filter(col("b").eq(lit(true)))?+ .filter(col("c").eq(lit(false)))?+ .project(vec![col("a")])?+ .build()?;let expected = "\Projection: test.a\@@ -261,23 +249,18 @@ mod tests {\n Filter: test.b\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn test_simplity_optimized_plan_not_eq_expr() {+ fn test_simplify_optimized_plan_not_eq_expr() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("b").not_eq(lit(true)))- .unwrap()- .filter(col("c").not_eq(lit(false)))- .unwrap()- .limit(0, Some(1))- .unwrap()- .project(vec![col("a")])- .unwrap()- .build()- .unwrap();+ .filter(col("b").not_eq(lit(true)))?+ .filter(col("c").not_eq(lit(false)))?+ .limit(0, Some(1))?+ .project(vec![col("a")])?+ .build()?;let expected = "\Projection: test.a\@@ -286,109 +269,95 @@ mod tests {\n Filter: NOT test.b\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn test_simplity_optimized_plan_and_expr() {+ fn test_simplify_optimized_plan_and_expr() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("b").not_eq(lit(true)).and(col("c").eq(lit(true))))- .unwrap()- .project(vec![col("a")])- .unwrap()- .build()- .unwrap();+ .filter(col("b").not_eq(lit(true)).and(col("c").eq(lit(true))))?+ .project(vec![col("a")])?+ .build()?;let expected = "\Projection: test.a\\n Filter: NOT test.b AND test.c\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn test_simplity_optimized_plan_or_expr() {+ fn test_simplify_optimized_plan_or_expr() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("b").not_eq(lit(true)).or(col("c").eq(lit(false))))- .unwrap()- .project(vec![col("a")])- .unwrap()- .build()- .unwrap();+ .filter(col("b").not_eq(lit(true)).or(col("c").eq(lit(false))))?+ .project(vec![col("a")])?+ .build()?;let expected = "\Projection: test.a\\n Filter: NOT test.b OR NOT test.c\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn test_simplity_optimized_plan_not_expr() {+ fn test_simplify_optimized_plan_not_expr() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("b").eq(lit(false)).not())- .unwrap()- .project(vec![col("a")])- .unwrap()- .build()- .unwrap();+ .filter(col("b").eq(lit(false)).not())?+ .project(vec![col("a")])?+ .build()?;let expected = "\Projection: test.a\\n Filter: test.b\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn test_simplity_optimized_plan_support_projection() {+ fn test_simplify_optimized_plan_support_projection() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .project(vec![col("a"), col("d"), col("b").eq(lit(false))])- .unwrap()- .build()- .unwrap();+ .project(vec![col("a"), col("d"), col("b").eq(lit(false))])?+ .build()?;let expected = "\Projection: test.a, test.d, NOT test.b AS test.b = Boolean(false)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn test_simplity_optimized_plan_support_aggregate() {+ fn test_simplify_optimized_plan_support_aggregate() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .project(vec![col("a"), col("c"), col("b")])- .unwrap()+ .project(vec![col("a"), col("c"), col("b")])?.aggregate(vec![col("a"), col("c")],vec![datafusion_expr::max(col("b").eq(lit(true))),datafusion_expr::min(col("b")),],- )- .unwrap()- .build()- .unwrap();+ )?+ .build()?;let expected = "\Aggregate: groupBy=[[test.a, test.c]], aggr=[[MAX(test.b) AS MAX(test.b = Boolean(true)), MIN(test.b)]]\\n Projection: test.a, test.c, test.b\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn test_simplity_optimized_plan_support_values() {+ fn test_simplify_optimized_plan_support_values() -> Result<()> {let expr1 = Expr::BinaryExpr(BinaryExpr::new(Box::new(lit(1)),Operator::Plus,@@ -400,12 +369,12 @@ mod tests {Box::new(lit(1)),));let values = vec![vec![expr1, expr2]];- let plan = LogicalPlanBuilder::values(values).unwrap().build().unwrap();+ let plan = LogicalPlanBuilder::values(values)?.build()?;let expected = "\Values: (Int32(3) AS Int32(1) + Int32(2), Int32(1) AS Int32(2) - Int32(1))";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}// expect optimizing will result in an error, returning the error string@@ -436,79 +405,73 @@ mod tests {}#[test]- fn to_timestamp_expr_folded() {+ fn to_timestamp_expr_folded() -> Result<()> {let table_scan = test_table_scan();let proj = vec![to_timestamp_expr("2020-09-08T12:00:00+00:00")];let plan = LogicalPlanBuilder::from(table_scan)- .project(proj)- .unwrap()- .build()- .unwrap();+ .project(proj)?+ .build()?;let expected = "Projection: TimestampNanosecond(1599566400000000000, None) AS totimestamp(Utf8(\"2020-09-08T12:00:00+00:00\"))\\n TableScan: test".to_string();let actual = get_optimized_plan_formatted(&plan, &Utc::now());assert_eq!(expected, actual);+ Ok(())}#[test]- fn to_timestamp_expr_wrong_arg() {+ fn to_timestamp_expr_wrong_arg() -> Result<()> {let table_scan = test_table_scan();let proj = vec![to_timestamp_expr("I'M NOT A TIMESTAMP")];let plan = LogicalPlanBuilder::from(table_scan)- .project(proj)- .unwrap()- .build()- .unwrap();+ .project(proj)?+ .build()?;let expected = "Error parsing 'I'M NOT A TIMESTAMP' as timestamp";let actual = get_optimized_plan_err(&plan, &Utc::now());assert_contains!(actual, expected);+ Ok(())}#[test]- fn cast_expr() {+ fn cast_expr() -> Result<()> {let table_scan = test_table_scan();let proj = vec![Expr::Cast(Cast::new(Box::new(lit("0")), DataType::Int32))];let plan = LogicalPlanBuilder::from(table_scan)- .project(proj)- .unwrap()- .build()- .unwrap();+ .project(proj)?+ .build()?;let expected = "Projection: Int32(0) AS Utf8(\"0\")\\n TableScan: test";let actual = get_optimized_plan_formatted(&plan, &Utc::now());assert_eq!(expected, actual);+ Ok(())}#[test]- fn cast_expr_wrong_arg() {+ fn cast_expr_wrong_arg() -> Result<()> {let table_scan = test_table_scan();let proj = vec![Expr::Cast(Cast::new(Box::new(lit("")), DataType::Int32))];let plan = LogicalPlanBuilder::from(table_scan)- .project(proj)- .unwrap()- .build()- .unwrap();+ .project(proj)?+ .build()?;let expected = "Cannot cast string '' to value of Int32 type";let actual = get_optimized_plan_err(&plan, &Utc::now());assert_contains!(actual, expected);+ Ok(())}#[test]- fn multiple_now_expr() {+ fn multiple_now_expr() -> Result<()> {let table_scan = test_table_scan();let time = Utc::now();let proj = vec![now_expr(), now_expr().alias("t2")];let plan = LogicalPlanBuilder::from(table_scan)- .project(proj)- .unwrap()- .build()- .unwrap();+ .project(proj)?+ .build()?;// expect the same timestamp appears in both exprslet actual = get_optimized_plan_formatted(&plan, &time);@@ -520,10 +483,11 @@ mod tests {);assert_eq!(expected, actual);+ Ok(())}#[test]- fn simplify_and_eval() {+ fn simplify_and_eval() -> Result<()> {// demonstrate a case where the evaluation needs to run prior// to the simplifier for it to worklet table_scan = test_table_scan();@@ -531,10 +495,8 @@ mod tests {// (true or false) != col --> !collet proj = vec![lit(true).or(lit(false)).not_eq(col("a"))];let plan = LogicalPlanBuilder::from(table_scan)- .project(proj)- .unwrap()- .build()- .unwrap();+ .project(proj)?+ .build()?;let actual = get_optimized_plan_formatted(&plan, &time);let expected =@@ -542,10 +504,11 @@ mod tests {\n TableScan: test";assert_eq!(expected, actual);+ Ok(())}#[test]- fn now_less_than_timestamp() {+ fn now_less_than_timestamp() -> Result<()> {let table_scan = test_table_scan();let ts_string = "2020-09-08T12:05:00+00:00";@@ -554,14 +517,10 @@ mod tests {// cast(now() as int) < cast(to_timestamp(...) as int) + 50000_i64let plan =LogicalPlanBuilder::from(table_scan)- .filter(- cast_to_int64_expr(now_expr())- .lt(cast_to_int64_expr(to_timestamp_expr(ts_string))- + lit(50000_i64)),- )- .unwrap()- .build()- .unwrap();+ .filter(cast_to_int64_expr(now_expr()).lt(cast_to_int64_expr(+ to_timestamp_expr(ts_string),+ ) + lit(50000_i64)))?+ .build()?;// Note that constant folder runs and folds the entire// expression down to a single constant (true)@@ -570,10 +529,11 @@ mod tests {let actual = get_optimized_plan_formatted(&plan, &time);assert_eq!(expected, actual);+ Ok(())}#[test]- fn select_date_plus_interval() {+ fn select_date_plus_interval() -> Result<()> {let table_scan = test_table_scan();let ts_string = "2020-09-08T12:05:00+00:00";@@ -583,15 +543,12 @@ mod tests {let schema = table_scan.schema();let date_plus_interval_expr = to_timestamp_expr(ts_string)- .cast_to(&DataType::Date32, schema)- .unwrap()+ .cast_to(&DataType::Date32, schema)?+ Expr::Literal(ScalarValue::IntervalDayTime(Some(123i64 << 32)));let plan = LogicalPlanBuilder::from(table_scan.clone())- .project(vec![date_plus_interval_expr])- .unwrap()- .build()- .unwrap();+ .project(vec![date_plus_interval_expr])?+ .build()?;// Note that constant folder runs and folds the entire// expression down to a single constant (true)@@ -600,132 +557,117 @@ mod tests {let actual = get_optimized_plan_formatted(&plan, &time);assert_eq!(expected, actual);+ Ok(())}#[test]- fn simplify_not_binary() {+ fn simplify_not_binary() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").gt(lit(10)).not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").gt(lit(10)).not())?+ .build()?;let expected = "Filter: test.d <= Int32(10)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_bool_and() {+ fn simplify_not_bool_and() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").gt(lit(10)).and(col("d").lt(lit(100))).not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").gt(lit(10)).and(col("d").lt(lit(100))).not())?+ .build()?;let expected = "Filter: test.d <= Int32(10) OR test.d >= Int32(100)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_bool_or() {+ fn simplify_not_bool_or() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").gt(lit(10)).or(col("d").lt(lit(100))).not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").gt(lit(10)).or(col("d").lt(lit(100))).not())?+ .build()?;let expected = "Filter: test.d <= Int32(10) AND test.d >= Int32(100)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_not() {+ fn simplify_not_not() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").gt(lit(10)).not().not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").gt(lit(10)).not().not())?+ .build()?;let expected = "Filter: test.d > Int32(10)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_null() {+ fn simplify_not_null() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").is_null().not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").is_null().not())?+ .build()?;let expected = "Filter: test.d IS NOT NULL\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_not_null() {+ fn simplify_not_not_null() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").is_not_null().not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").is_not_null().not())?+ .build()?;let expected = "Filter: test.d IS NULL\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_in() {+ fn simplify_not_in() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").in_list(vec![lit(1), lit(2), lit(3)], false).not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").in_list(vec![lit(1), lit(2), lit(3)], false).not())?+ .build()?;let expected ="Filter: test.d != Int32(3) AND test.d != Int32(2) AND test.d != Int32(1)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_not_in() {+ fn simplify_not_not_in() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("d").in_list(vec![lit(1), lit(2), lit(3)], true).not())- .unwrap()- .build()- .unwrap();+ .filter(col("d").in_list(vec![lit(1), lit(2), lit(3)], true).not())?+ .build()?;let expected ="Filter: test.d = Int32(3) OR test.d = Int32(2) OR test.d = Int32(1)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_between() {+ fn simplify_not_between() -> Result<()> {let table_scan = test_table_scan();let qual = Expr::Between(Between::new(Box::new(col("d")),@@ -735,18 +677,16 @@ mod tests {));let plan = LogicalPlanBuilder::from(table_scan)- .filter(qual.not())- .unwrap()- .build()- .unwrap();+ .filter(qual.not())?+ .build()?;let expected = "Filter: test.d < Int32(1) OR test.d > Int32(10)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_not_between() {+ fn simplify_not_not_between() -> Result<()> {let table_scan = test_table_scan();let qual = Expr::Between(Between::new(Box::new(col("d")),@@ -756,18 +696,16 @@ mod tests {));let plan = LogicalPlanBuilder::from(table_scan)- .filter(qual.not())- .unwrap()- .build()- .unwrap();+ .filter(qual.not())?+ .build()?;let expected = "Filter: test.d >= Int32(1) AND test.d <= Int32(10)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_like() {+ fn simplify_not_like() -> Result<()> {let schema = Schema::new(vec![Field::new("a", DataType::Utf8, false),Field::new("b", DataType::Utf8, false),@@ -778,18 +716,16 @@ mod tests {.expect("building plan");let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("a").like(col("b")).not())- .unwrap()- .build()- .unwrap();+ .filter(col("a").like(col("b")).not())?+ .build()?;let expected = "Filter: test.a NOT LIKE test.b\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_not_like() {+ fn simplify_not_not_like() -> Result<()> {let schema = Schema::new(vec![Field::new("a", DataType::Utf8, false),Field::new("b", DataType::Utf8, false),@@ -800,43 +736,37 @@ mod tests {.expect("building plan");let plan = LogicalPlanBuilder::from(table_scan)- .filter(col("a").not_like(col("b")).not())- .unwrap()- .build()- .unwrap();+ .filter(col("a").not_like(col("b")).not())?+ .build()?;let expected = "Filter: test.a LIKE test.b\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_distinct_from() {+ fn simplify_not_distinct_from() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(binary_expr(col("d"), Operator::IsDistinctFrom, lit(10)).not())- .unwrap()- .build()- .unwrap();+ .filter(binary_expr(col("d"), Operator::IsDistinctFrom, lit(10)).not())?+ .build()?;let expected = "Filter: test.d IS NOT DISTINCT FROM Int32(10)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}#[test]- fn simplify_not_not_distinct_from() {+ fn simplify_not_not_distinct_from() -> Result<()> {let table_scan = test_table_scan();let plan = LogicalPlanBuilder::from(table_scan)- .filter(binary_expr(col("d"), Operator::IsNotDistinctFrom, lit(10)).not())- .unwrap()- .build()- .unwrap();+ .filter(binary_expr(col("d"), Operator::IsNotDistinctFrom, lit(10)).not())?+ .build()?;let expected = "Filter: test.d IS DISTINCT FROM Int32(10)\\n TableScan: test";- assert_optimized_plan_eq(&plan, expected);+ assert_optimized_plan_eq(&plan, expected)}}