Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: small clean up #47

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rust/quary-databases/src/databases_duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
rows.push(row);
}

for i in 0..num_rows {

Check warning on line 230 in rust/quary-databases/src/databases_duckdb.rs

View workflow job for this annotation

GitHub Actions / Rust Lint

the loop variable `i` is used to index `rows`
for j in 0..array.len() {
let array = &array[j];
if let Some(string_array) = array.as_any().downcast_ref::<array::StringArray>() {
Expand Down Expand Up @@ -863,10 +863,10 @@

// Parse the string into a NaiveDateTime
let naive_datetime = NaiveDateTime::parse_from_str(datetime_str, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

// Convert NaiveDateTime to DateTime<Utc>
let datetime_utc = DateTime::<Utc>::from_utc(naive_datetime, Utc);

Check warning on line 869 in rust/quary-databases/src/databases_duckdb.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead

// Convert DateTime<Utc> to SystemTime
let system_time = SystemTime::from(datetime_utc);
Expand Down Expand Up @@ -984,9 +984,9 @@
// Parse the string into a NaiveDateTime
let naive_datetime_updated =
NaiveDateTime::parse_from_str(datetime_str_updated, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

// Convert NaiveDateTime to DateTime<Utc>

Check warning on line 989 in rust/quary-databases/src/databases_duckdb.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead
let datetime_utc_updated = DateTime::<Utc>::from_utc(naive_datetime_updated, Utc);

// Convert DateTime<Utc> to SystemTime
Expand Down Expand Up @@ -1071,9 +1071,9 @@

// Parse the string into a NaiveDateTime
let naive_datetime = NaiveDateTime::parse_from_str(datetime_str, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

// Convert NaiveDateTime to DateTime<Utc>

Check warning on line 1076 in rust/quary-databases/src/databases_duckdb.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead
let datetime_utc = DateTime::<Utc>::from_utc(naive_datetime, Utc);

// Convert DateTime<Utc> to SystemTime
Expand Down Expand Up @@ -1192,8 +1192,8 @@
// Parse the string into a NaiveDateTime
let naive_datetime_updated =
NaiveDateTime::parse_from_str(datetime_str_updated, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

Check warning on line 1196 in rust/quary-databases/src/databases_duckdb.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead
// Convert NaiveDateTime to DateTime<Utc>
let datetime_utc_updated = DateTime::<Utc>::from_utc(naive_datetime_updated, Utc);

Expand Down
20 changes: 10 additions & 10 deletions rust/quary-databases/src/databases_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

impl Postgres {
// TODO This should be a builder pattern or something else
pub async fn new(

Check warning on line 24 in rust/quary-databases/src/databases_postgres.rs

View workflow job for this annotation

GitHub Actions / Rust Lint

this function has too many arguments (12/7)
host: &str,
port: Option<String>,
user: &str,
Expand Down Expand Up @@ -110,7 +110,7 @@
.map(|row| {
let table_schema: String = row
.try_get(0)
.map_err(|e| format!("Error getting table schema: {}", e.to_string()))?;

Check warning on line 113 in rust/quary-databases/src/databases_postgres.rs

View workflow job for this annotation

GitHub Actions / Rust Lint

`to_string` applied to a type that implements `Display` in `format!` args
let table_name: String = row
.try_get(1)
.map_err(|e| format!("Error getting table name: {}", e.to_string()))?;
Expand Down Expand Up @@ -372,7 +372,7 @@
None,
)
.await
.expect("Failed to instantiate Quary Postgres");
.unwrap();

let filesystem = FileSystem {
files: vec![
Expand Down Expand Up @@ -442,7 +442,7 @@
None,
)
.await
.expect("Failed to instantiate Quary Postgres");
.unwrap();

quary_postgres
.exec("CREATE TABLE wrong_table (id INTEGER, name VARCHAR(255))")
Expand Down Expand Up @@ -553,7 +553,7 @@
None,
)
.await
.expect("Failed to instantiate Quary Postgres");
.unwrap();

database.exec("CREATE SCHEMA transform").await.unwrap();
database
Expand Down Expand Up @@ -633,7 +633,7 @@
None,
)
.await
.expect("Failed to instantiate Quary Postgres");
.unwrap();

database.exec("CREATE SCHEMA other_schema").await.unwrap();
database.exec("CREATE SCHEMA transform").await.unwrap();
Expand Down Expand Up @@ -730,7 +730,7 @@
let results = database
.query(test)
.await
.expect(&format!("Error running query {}", test));
.unwrap();

assert_eq!(results.rows.len(), 0, "test {} failed: {}", name, test);
}
Expand Down Expand Up @@ -759,7 +759,7 @@
None,
)
.await
.expect("Failed to instantiate Quary Postgres");
.unwrap();

database.exec("CREATE SCHEMA other_schema").await.unwrap();
database.exec("CREATE SCHEMA transform").await.unwrap();
Expand Down Expand Up @@ -879,7 +879,7 @@
let results = database
.query(test)
.await
.expect(&format!("Error running query {}", test));
.unwrap();

assert_eq!(results.rows.len(), 0, "test {} failed: {}", name, test);
}
Expand Down Expand Up @@ -908,7 +908,7 @@
None,
)
.await
.expect("Failed to instantiate Quary Postgres");
.unwrap();

database.exec("CREATE SCHEMA other_schema").await.unwrap();
database.exec("CREATE SCHEMA transform").await.unwrap();
Expand Down Expand Up @@ -1174,10 +1174,10 @@
database.exec("CREATE SCHEMA jaffle_shop").await.unwrap();

let datetime_str = "2023-01-01 01:00:00";

Check warning on line 1177 in rust/quary-databases/src/databases_postgres.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead
// Parse the string into a NaiveDateTime
let naive_datetime = NaiveDateTime::parse_from_str(datetime_str, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

// Convert NaiveDateTime to DateTime<Utc>
let datetime_utc = DateTime::<Utc>::from_utc(naive_datetime, Utc);
Expand Down Expand Up @@ -1297,11 +1297,11 @@
.unwrap();

let datetime_str_updated = "2023-01-01 03:00:00";

Check warning on line 1300 in rust/quary-databases/src/databases_postgres.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead
// Parse the string into a NaiveDateTime
let naive_datetime_updated =
NaiveDateTime::parse_from_str(datetime_str_updated, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

// Convert NaiveDateTime to DateTime<Utc>
let datetime_utc_updated = DateTime::<Utc>::from_utc(naive_datetime_updated, Utc);
Expand Down
18 changes: 9 additions & 9 deletions rust/quary-databases/src/databases_redshift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
async fn test_redshift_list_tables_and_views() {
let quary_postgres = Redshift::new("", None, "", "", "", "", None, None, None, None, None)
.await
.expect("Failed to instantiate Quary Redshift");
.unwrap();

quary_postgres
.exec("CREATE TABLE wrong_table (id INTEGER, name VARCHAR(255))")
Expand Down Expand Up @@ -220,7 +220,7 @@
async fn test_redshift_list_columns_in_table() {
let database = Redshift::new("", None, "", "", "", "", None, None, None, None, None)
.await
.expect("Failed to instantiate Quary Redshift");
.unwrap();

database
.exec("CREATE SCHEMA IF NOT EXISTS transform")
Expand Down Expand Up @@ -288,7 +288,7 @@
async fn test_redshift_foreign_relationship_test_with_schema() {
let database = Redshift::new("", None, "", "", "", "", None, None, None, None, None)
.await
.expect("Failed to instantiate Quary Redshift");
.unwrap();

database
.exec("CREATE SCHEMA IF NOT EXISTS other_schema")
Expand Down Expand Up @@ -391,7 +391,7 @@
let results = database
.query(test)
.await
.expect(&format!("Error running query {}", test));
.unwrap();

assert_eq!(results.rows.len(), 0, "test {} failed: {}", name, test);
}
Expand All @@ -404,7 +404,7 @@
async fn test_redshift_foreign_relationship_test_with_materialized_view_table() {
let database = Redshift::new("", None, "", "", "", "", None, None, None, None, None)
.await
.expect("Failed to instantiate Quary Redshift");
.unwrap();

database
.exec("CREATE SCHEMA IF NOT EXISTS other_schema")
Expand Down Expand Up @@ -530,7 +530,7 @@
let results = database
.query(test)
.await
.expect(&format!("Error running query {}", test));
.unwrap();

assert_eq!(results.rows.len(), 0, "test {} failed: {}", name, test);
}
Expand All @@ -541,7 +541,7 @@
async fn test_list_tables_outside_the_schema() {
let database = Redshift::new("", None, "", "", "", "", None, None, None, None, None)
.await
.expect("Failed to instantiate Quary Postgres");
.unwrap();

database.exec("CREATE SCHEMA other_schema").await.unwrap();
database.exec("CREATE SCHEMA transform").await.unwrap();
Expand Down Expand Up @@ -658,10 +658,10 @@
database.exec("CREATE SCHEMA jaffle_shop").await.unwrap();

let datetime_str = "2023-01-01 01:00:00";

Check warning on line 661 in rust/quary-databases/src/databases_redshift.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead
// Parse the string into a NaiveDateTime
let naive_datetime = NaiveDateTime::parse_from_str(datetime_str, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

// Convert NaiveDateTime to DateTime<Utc>
let datetime_utc = DateTime::<Utc>::from_utc(naive_datetime, Utc);
Expand Down Expand Up @@ -782,11 +782,11 @@
.unwrap();

let datetime_str_updated = "2023-01-01 03:00:00";

Check warning on line 785 in rust/quary-databases/src/databases_redshift.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated associated function `chrono::DateTime::<Tz>::from_utc`: Use TimeZone::from_utc_datetime() or DateTime::from_naive_utc_and_offset instead
// Parse the string into a NaiveDateTime
let naive_datetime_updated =
NaiveDateTime::parse_from_str(datetime_str_updated, "%Y-%m-%d %H:%M:%S")
.expect("Failed to parse datetime string");
.unwrap();

// Convert NaiveDateTime to DateTime<Utc>
let datetime_utc_updated = DateTime::<Utc>::from_utc(naive_datetime_updated, Utc);
Expand Down
Loading