Skip to content
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
4 changes: 4 additions & 0 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub enum CompressionCodec {
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct CloudSettings {
pub s3_region: Option<String>,
pub s3_profile: Option<String>,
pub s3_access_key_id: Option<String>,
pub gcs_project_id: Option<String>,
pub azure_storage_account_name: Option<String>,
Expand Down Expand Up @@ -385,6 +386,9 @@ impl DuckDbEngine {
if let Some(region) = &cloud.s3_region {
self.set_option("s3_region", region)?;
}
if let Some(profile) = &cloud.s3_profile {
self.set_option("s3_profile", profile)?;
}
if let Some(access_key_id) = &cloud.s3_access_key_id {
self.set_option("s3_access_key_id", access_key_id)?;
}
Expand Down
10 changes: 9 additions & 1 deletion src/file_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct FileResolverConfig {
pub delimiter: char,
pub on_error: OnErrorMode,
pub s3_region: Option<String>,
pub s3_profile: Option<String>,
pub gcs_project: Option<String>,
pub azure_account: Option<String>,
}
Expand All @@ -66,6 +67,7 @@ impl Default for FileResolverConfig {
delimiter: ',',
on_error: OnErrorMode::Fail,
s3_region: None,
s3_profile: None,
gcs_project: None,
azure_account: None,
}
Expand Down Expand Up @@ -176,6 +178,9 @@ impl FileResolver {
if let Some(region) = &self.config.s3_region {
set_sql_option(&conn, "s3_region", region)?;
}
if let Some(profile) = &self.config.s3_profile {
set_sql_option(&conn, "s3_profile", profile)?;
}
if let Some(project) = &self.config.gcs_project {
set_sql_option(&conn, "gcs_project_id", project)?;
}
Expand Down Expand Up @@ -383,7 +388,10 @@ fn set_sql_option(connection: &Connection, key: &str, value: &str) -> Result<(),
}

fn is_cloud_path(path: &str) -> bool {
path.starts_with("s3://") || path.starts_with("gs://") || path.starts_with("az://")
path.starts_with("s3://")
|| path.starts_with("gs://")
|| path.starts_with("az://")
|| path.starts_with("abfss://")
}

fn escape_sql_literal(value: &str) -> String {
Expand Down
5 changes: 4 additions & 1 deletion src/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ pub fn fingerprint_file(path: &Path) -> Result<String, DtooError> {

fn is_cloud_path(path: &Path) -> bool {
let value = path.to_string_lossy();
value.starts_with("s3://") || value.starts_with("gs://") || value.starts_with("az://")
value.starts_with("s3://")
|| value.starts_with("gs://")
|| value.starts_with("az://")
|| value.starts_with("abfss://")
}

fn download_cloud_blob(path: &Path) -> Result<PathBuf, DtooError> {
Expand Down
27 changes: 26 additions & 1 deletion src/query_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@ impl QueryPipeline {
let engine = DuckDbEngine::new(EngineConfig {
cloud: CloudSettings {
s3_region: args.s3_region.clone(),
s3_profile: args.s3_profile.clone(),
s3_access_key_id: None,
gcs_project_id: args.gcs_project.clone(),
azure_storage_account_name: args.azure_account.clone(),
},
load_extensions: false,
load_extensions: requires_cloud_extensions(args, &files),
})?;

if let Some(schema_path) = &args.schema {
Expand Down Expand Up @@ -422,6 +423,7 @@ fn resolve_files(args: &QueryArgs) -> Result<ResolutionReport, DtooError> {
delimiter: args.delimiter,
on_error: args.on_error,
s3_region: args.s3_region.clone(),
s3_profile: args.s3_profile.clone(),
gcs_project: args.gcs_project.clone(),
azure_account: args.azure_account.clone(),
});
Expand Down Expand Up @@ -669,6 +671,29 @@ fn describe_input_source(args: &QueryArgs) -> String {
"explicit paths".to_string()
}

fn requires_cloud_extensions(
args: &QueryArgs,
files: &[crate::file_resolution::ResolvedFile],
) -> bool {
files.iter().any(|file| is_cloud_path(&file.path))
|| args
.refs
.iter()
.filter_map(|entry| entry.split_once('='))
.any(|(_, path)| is_cloud_path(path.trim()))
|| args
.output
.as_ref()
.is_some_and(|path| is_cloud_path(path.to_string_lossy().as_ref()))
}

fn is_cloud_path(path: &str) -> bool {
path.starts_with("s3://")
|| path.starts_with("gs://")
|| path.starts_with("az://")
|| path.starts_with("abfss://")
}

fn write_manifest_if_requested(
args: &QueryArgs,
summary: &PipelineResult,
Expand Down
5 changes: 4 additions & 1 deletion src/reference_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ fn is_valid_identifier(name: &str) -> bool {
}

fn is_cloud_path(path: &str) -> bool {
path.starts_with("s3://") || path.starts_with("gs://") || path.starts_with("az://")
path.starts_with("s3://")
|| path.starts_with("gs://")
|| path.starts_with("az://")
|| path.starts_with("abfss://")
}

fn split_excel_sheet_from_path(path: &str) -> (String, Option<String>) {
Expand Down
Loading