Skip to content

Commit

Permalink
Minor: Do what clippy says and clean up some code (#4007)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb authored Oct 30, 2022
1 parent d6f0b12 commit f4d70ac
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/tests/sql/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::*;
#[tokio::test]
async fn csv_query_error() -> Result<()> {
// sin(utf8) should error
let ctx = create_ctx()?;
let ctx = create_ctx();
register_aggregate_csv(&ctx).await?;
let sql = "SELECT sin(c1) FROM aggregate_test_100";
let plan = ctx.create_logical_plan(sql);
Expand All @@ -31,7 +31,7 @@ async fn csv_query_error() -> Result<()> {
#[tokio::test]
async fn test_cast_expressions_error() -> Result<()> {
// sin(utf8) should error
let ctx = create_ctx()?;
let ctx = create_ctx();
register_aggregate_csv(&ctx).await?;
let sql = "SELECT CAST(c1 AS INT) FROM aggregate_test_100";
let plan = ctx.create_logical_plan(sql).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions datafusion/core/tests/sql/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ async fn test_cast_expressions() -> Result<()> {

#[tokio::test]
async fn test_random_expression() -> Result<()> {
let ctx = create_ctx()?;
let ctx = create_ctx();
let sql = "SELECT random() r1";
let actual = execute(&ctx, sql).await;
let r1 = actual[0][0].parse::<f64>().unwrap();
Expand Down Expand Up @@ -1480,7 +1480,7 @@ async fn csv_count_star() -> Result<()> {

#[tokio::test]
async fn csv_query_avg_sqrt() -> Result<()> {
let ctx = create_ctx()?;
let ctx = create_ctx();
register_aggregate_csv(&ctx).await?;
let sql = "SELECT avg(custom_sqrt(c12)) FROM aggregate_test_100";
let mut actual = execute(&ctx, sql).await;
Expand All @@ -1493,7 +1493,7 @@ async fn csv_query_avg_sqrt() -> Result<()> {
// this query used to deadlock due to the call udf(udf())
#[tokio::test]
async fn csv_query_sqrt_sqrt() -> Result<()> {
let ctx = create_ctx()?;
let ctx = create_ctx();
register_aggregate_csv(&ctx).await?;
let sql = "SELECT sqrt(sqrt(c12)) FROM aggregate_test_100 LIMIT 1";
let actual = execute(&ctx, sql).await;
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/sql/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::*;

#[tokio::test]
async fn sqrt_f32_vs_f64() -> Result<()> {
let ctx = create_ctx()?;
let ctx = create_ctx();
register_aggregate_csv(&ctx).await?;
// sqrt(f32)'s plan passes
let sql = "SELECT avg(sqrt(c11)) FROM aggregate_test_100";
Expand Down
5 changes: 2 additions & 3 deletions datafusion/core/tests/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ where
});
}

#[allow(clippy::unnecessary_wraps)]
fn create_ctx() -> Result<SessionContext> {
fn create_ctx() -> SessionContext {
let mut ctx = SessionContext::new();

// register a custom UDF
Expand All @@ -147,7 +146,7 @@ fn create_ctx() -> Result<SessionContext> {
Arc::new(custom_sqrt),
));

Ok(ctx)
ctx
}

fn custom_sqrt(args: &[ColumnarValue]) -> Result<ColumnarValue> {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/sql/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use datafusion_expr::{create_udaf, LogicalPlanBuilder};
/// physical plan have the same schema.
#[tokio::test]
async fn csv_query_custom_udf_with_cast() -> Result<()> {
let ctx = create_ctx()?;
let ctx = create_ctx();
register_aggregate_csv(&ctx).await?;
let sql = "SELECT avg(custom_sqrt(c11)) FROM aggregate_test_100";
let actual = execute(&ctx, sql).await;
Expand Down

0 comments on commit f4d70ac

Please sign in to comment.