Skip to content

Commit

Permalink
lint: disable warn on unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
timvw committed Mar 26, 2024
1 parent fe1d09b commit 77cfe3b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
11 changes: 9 additions & 2 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::GlobbingPath;
//use crate::GlobbingPath;
use aws_sdk_glue::Client;
use aws_types::SdkConfig;
use chrono::{DateTime, Utc};
Expand Down Expand Up @@ -50,6 +50,7 @@ impl Args {
query
}

/*
pub async fn get_globbing_path(&self) -> Result<GlobbingPath> {
let (data_location, maybe_sdk_config) = match update_s3_console_url(&self.path) {
(true, updated_location) => (updated_location, Some(get_sdk_config(self).await)),
Expand Down Expand Up @@ -79,29 +80,33 @@ impl Args {
let globbing_path = GlobbingPath::parse(&data_location)?;
Ok(globbing_path)
}
}*/
}

#[allow(dead_code)]
async fn get_sdk_config(args: &Args) -> SdkConfig {
set_aws_profile_when_needed(args);
set_aws_region_when_needed();

aws_config::load_from_env().await
}

#[allow(dead_code)]
fn set_aws_profile_when_needed(args: &Args) {
if let Some(aws_profile) = &args.profile {
env::set_var("AWS_PROFILE", aws_profile);
}
}

#[allow(dead_code)]
fn set_aws_region_when_needed() {
match env::var("AWS_DEFAULT_REGION") {
Ok(_) => {}
Err(_) => env::set_var("AWS_DEFAULT_REGION", "eu-central-1"),
}
}

#[allow(dead_code)]
async fn get_storage_location(
sdk_config: &SdkConfig,
database_name: &str,
Expand Down Expand Up @@ -140,6 +145,7 @@ async fn get_storage_location(
Ok(location.to_string())
}

#[allow(dead_code)]
fn parse_glue_url(s: &str) -> Option<(String, String)> {
let re: Regex = Regex::new(r"^glue://(\w+)\.(\w+)$").unwrap();
re.captures(s).map(|captures| {
Expand All @@ -160,6 +166,7 @@ fn test_parse_glue_url() {

/// When the provided s looks like an https url from the amazon webui convert it to an s3:// url
/// When the provided s does not like such url, return it as is.
#[allow(dead_code)]
fn update_s3_console_url(s: &str) -> (bool, String) {
if s.starts_with("https://s3.console.aws.amazon.com/s3/buckets/") {
let parsed_url = Url::parse(s).unwrap_or_else(|_| panic!("Failed to parse {}", s));
Expand Down
18 changes: 10 additions & 8 deletions src/globbing_path.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
use datafusion::common::{DataFusionError, Result};
use datafusion::datasource::listing::ListingTableUrl;
use datafusion::datasource::object_store::ObjectStoreUrl;
Expand Down Expand Up @@ -171,10 +172,10 @@ fn test_extract_path_parts() {
assert_eq!("a", actual.1.as_ref());
assert_eq!(Some(Pattern::new("a/b*").unwrap()), actual.2);
let actual = extract_path_parts("s3://bucket/a/b*/c").unwrap();
assert_eq!("s3://bucket/", actual.0.as_str());
assert_eq!("a", actual.1.as_ref());
assert_eq!(Some(Pattern::new("a/b*/c").unwrap()), actual.2);
// let actual = extract_path_parts("s3://bucket/a/b* /c").unwrap();
// assert_eq!("s3://bucket/", actual.0.as_str());
// assert_eq!("a", actual.1.as_ref());
// assert_eq!(Some(Pattern::new("a/b* /c").unwrap()), actual.2);
let actual = extract_path_parts("file://").unwrap();
assert_eq!("file:///", actual.0.as_str());
Expand All @@ -201,10 +202,10 @@ fn test_extract_path_parts() {
assert_eq!("", actual.1.as_ref());
assert_eq!(Some(Pattern::new("c*").unwrap()), actual.2);
let actual = extract_path_parts("file:///a/b*/c").unwrap();
assert_eq!("file:///", actual.0.as_str());
assert_eq!("a", actual.1.as_ref());
assert_eq!(Some(Pattern::new("a/b*/c").unwrap()), actual.2);
// let actual = extract_path_parts("file:///a/b* /c").unwrap();
// assert_eq!("file:///", actual.0.as_str());
// assert_eq!("a", actual.1.as_ref());
// assert_eq!(Some(Pattern::new("a/b* /c").unwrap()), actual.2);
}
/// Splits `path` at the first path segment containing a glob expression, returning
Expand Down Expand Up @@ -232,3 +233,4 @@ fn split_glob_expression(path: &str) -> Option<(&str, &str)> {
}
None

Check warning on line 234 in src/globbing_path.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/qv/qv/src/globbing_path.rs
}
*/
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;

use datafusion::common::Result;
use datafusion::datasource::listing::{
ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl,
ListingTable, ListingTableConfig, ListingTableUrl,
};
use datafusion::prelude::*;

Expand All @@ -15,7 +15,7 @@ mod globbing_table;
mod object_store_util;

use crate::args::Args;
use crate::globbing_path::GlobbingPath;
//use crate::globbing_path::GlobbingPath;
//use crate::globbing_table::build_table_provider;
//use crate::object_store_util::register_object_store;

Expand Down

0 comments on commit 77cfe3b

Please sign in to comment.