Skip to content

Commit

Permalink
clippy linting
Browse files Browse the repository at this point in the history
Signed-off-by: Devan <[email protected]>
  • Loading branch information
devanbenz committed Aug 3, 2024
1 parent 9813b8a commit c4cccf5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/duckdb/time_bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ impl Display for TimeBucketInput {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
TimeBucketInput::Date(input) => {
write!(f, "{}::DATE", input.to_string())
write!(f, "{}::DATE", input)
}
TimeBucketInput::Timestamp(input) => {
write!(f, "{}", input.to_string())
write!(f, "{}", input)
}
}
}
Expand All @@ -45,10 +45,10 @@ impl Display for TimeBucketOffset {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
TimeBucketOffset::Date(input) => {
write!(f, "DATE {}", input.to_string())
write!(f, "DATE {}", input)
}
TimeBucketOffset::Interval(input) => {
write!(f, "INTERVAL {}", input.to_string())
write!(f, "INTERVAL {}", input)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ pub fn duckdb_conn() -> duckdb::Connection {
duckdb::Connection::open_in_memory().unwrap()
}

#[allow(dead_code)]
pub fn time_series_record_batch() -> Result<RecordBatch> {
// Define the fields for each datatype
let fields = vec![
Expand Down
8 changes: 8 additions & 0 deletions tests/time_bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use shared::fixtures::arrow::primitive_setup_fdw_local_file_listing;
use shared::fixtures::tempfile::TempDir;
use sqlx::PgConnection;
use std::fs::File;
use time::Date;

#[rstest]
async fn test_time_bucket(mut conn: PgConnection, tempdir: TempDir) -> Result<()> {
Expand All @@ -46,6 +47,7 @@ async fn test_time_bucket(mut conn: PgConnection, tempdir: TempDir) -> Result<()
)
.execute(&mut conn);

#[allow(clippy::single_match)]
match "SELECT time_bucket(INTERVAL '2 DAY', timestamp::DATE) AS bucket, AVG(value) as avg_value FROM timeseries GROUP BY bucket ORDER BY bucket;".execute_result(&mut conn) {
Ok(_) => {}
Err(error) => {
Expand All @@ -56,6 +58,7 @@ async fn test_time_bucket(mut conn: PgConnection, tempdir: TempDir) -> Result<()
}
}

#[allow(clippy::single_match)]
match "SELECT time_bucket(INTERVAL '2 DAY') AS bucket, AVG(value) as avg_value FROM timeseries GROUP BY bucket ORDER BY bucket;".execute_result(&mut conn) {
Ok(_) => {
panic!(
Expand All @@ -75,5 +78,10 @@ async fn test_time_bucket(mut conn: PgConnection, tempdir: TempDir) -> Result<()

assert_eq!(10, data.len());

let data: Vec<(Date,)> = "SELECT time_bucket(INTERVAL '1 YEAR', timestamp::DATE) AS bucket, AVG(value) as avg_value FROM timeseries GROUP BY bucket ORDER BY bucket;"
.fetch_result(&mut conn).unwrap();

assert_eq!(1, data.len());

Ok(())
}

0 comments on commit c4cccf5

Please sign in to comment.