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

refactor: order of impl matches trait #48

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_bigquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use gcp_bigquery_client::error::BQError;
use gcp_bigquery_client::model::query_request::QueryRequest;
use gcp_bigquery_client::Client;
use google_cloud_auth::project::{create_token_source, Config};

Check warning on line 6 in rust/quary-databases/src/databases_bigquery.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated function `google_cloud_auth::project::create_token_source`: Use DefaultTokenSourceProvider instead

Check warning on line 6 in rust/quary-databases/src/databases_bigquery.rs

View workflow job for this annotation

GitHub Actions / Rust Lint

use of deprecated function `google_cloud_auth::project::create_token_source`: Use DefaultTokenSourceProvider instead
use google_cloud_auth::token_source::TokenSource;
use quary_core::database_bigquery::DatabaseQueryGeneratorBigQuery;
use quary_core::databases::{
Expand Down Expand Up @@ -101,7 +101,7 @@
sub: None,
};
// Assuming `create_token_source` returns a `Result<impl TokenSource, Error>`
let ts = create_token_source(config)

Check warning on line 104 in rust/quary-databases/src/databases_bigquery.rs

View workflow job for this annotation

GitHub Actions / Rust Test

use of deprecated function `google_cloud_auth::project::create_token_source`: Use DefaultTokenSourceProvider instead

Check warning on line 104 in rust/quary-databases/src/databases_bigquery.rs

View workflow job for this annotation

GitHub Actions / Rust Lint

use of deprecated function `google_cloud_auth::project::create_token_source`: Use DefaultTokenSourceProvider instead
.await
.map_err(|e| format!("Failed to create token source: {}", e))?;

Expand Down Expand Up @@ -280,14 +280,14 @@
})
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}

fn query_generator(&self) -> Box<dyn DatabaseQueryGenerator> {
Box::new(DatabaseQueryGeneratorBigQuery::new(
self.project_id.to_string(),
self.dataset_id.to_string(),
))
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}
}
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 @@ -209,13 +209,13 @@
})
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}

fn query_generator(&self) -> Box<dyn DatabaseQueryGenerator> {
Box::new(DatabaseQueryGeneratorDuckDB::new(self.schema.clone(), None))
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}
}

fn convert_array_to_vec_string(array: &[Arc<dyn Array>]) -> Result<Vec<Vec<String>>, String> {
Expand All @@ -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 @@ -866,7 +866,7 @@
.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 @@ -986,7 +986,7 @@
NaiveDateTime::parse_from_str(datetime_str_updated, "%Y-%m-%d %H:%M:%S")
.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 @@ -1073,7 +1073,7 @@
let naive_datetime = NaiveDateTime::parse_from_str(datetime_str, "%Y-%m-%d %H:%M:%S")
.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 @@ -1193,7 +1193,7 @@
let naive_datetime_updated =
NaiveDateTime::parse_from_str(datetime_str_updated, "%Y-%m-%d %H:%M:%S")
.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
8 changes: 4 additions & 4 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 @@ -324,16 +324,16 @@
})
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}

fn query_generator(&self) -> Box<dyn DatabaseQueryGenerator> {
Box::new(DatabaseQueryGeneratorPostgres::new(
self.schema.clone(),
None,
))
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}
}

#[cfg(test)]
Expand Down Expand Up @@ -1174,7 +1174,7 @@
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")
.unwrap();
Expand Down Expand Up @@ -1297,7 +1297,7 @@
.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")
Expand Down
14 changes: 7 additions & 7 deletions rust/quary-databases/src/databases_redshift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
self.postgres.query(query).await
}

fn query_generator(&self) -> Box<dyn DatabaseQueryGenerator> {
Box::new(DatabaseQueryGeneratorRedshift::new(
self.schema.clone(),
None,
))
}

async fn table_exists(&self, path: &str) -> Result<Option<bool>, String> {
let parts: Vec<&str> = path.split('.').collect();
let (schema, table) = match parts.len() {
Expand All @@ -100,13 +107,6 @@
.await?;
Ok(Some(result.len() > 0))
}

fn query_generator(&self) -> Box<dyn DatabaseQueryGenerator> {
Box::new(DatabaseQueryGeneratorRedshift::new(
self.schema.clone(),
None,
))
}
}

#[cfg(test)]
Expand Down Expand Up @@ -658,7 +658,7 @@
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")
.unwrap();
Expand Down Expand Up @@ -782,7 +782,7 @@
.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")
Expand Down
8 changes: 4 additions & 4 deletions rust/quary-databases/src/databases_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,16 @@ impl DatabaseConnection for Snowflake {
};
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}

fn query_generator(&self) -> Box<dyn DatabaseQueryGenerator> {
Box::new(DatabaseQueryGeneratorSnowflake::new(
self.database.to_string(),
self.schema.to_string(),
))
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}
}

pub fn convert_array_to_vec_string(
Expand Down
8 changes: 4 additions & 4 deletions rust/quary-databases/src/databases_sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ impl DatabaseConnection for Sqlite {
})
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}

fn query_generator(&self) -> Box<dyn DatabaseQueryGenerator> {
Box::new(DatabaseQueryGeneratorSqlite {})
}

async fn table_exists(&self, _path: &str) -> Result<Option<bool>, String> {
Ok(None) // not implemented
}
}

#[cfg(test)]
Expand Down
Loading