mirror of
https://github.com/nushell/nushell.git
synced 2025-01-03 04:50:28 +01:00
You will now receive an error when trying to use a s3 url with avro or json
This commit is contained in:
parent
13bc9508d0
commit
d723a4e77e
@ -295,6 +295,10 @@ fn from_avro(
|
||||
) -> Result<Value, ShellError> {
|
||||
let file_path = resource.path;
|
||||
let file_span = resource.span;
|
||||
if resource.cloud_options.is_some() {
|
||||
return Err(cloud_not_supported(PolarsFileType::Avro, file_span));
|
||||
}
|
||||
|
||||
let columns: Option<Vec<String>> = call.get_flag("columns")?;
|
||||
let r = File::open(file_path).map_err(|e| ShellError::GenericError {
|
||||
error: "Error opening file".into(),
|
||||
@ -396,6 +400,9 @@ fn from_json(
|
||||
) -> Result<Value, ShellError> {
|
||||
let file_path = resource.path;
|
||||
let file_span = resource.span;
|
||||
if resource.cloud_options.is_some() {
|
||||
return Err(cloud_not_supported(PolarsFileType::Json, file_span));
|
||||
}
|
||||
let file = File::open(file_path).map_err(|e| ShellError::GenericError {
|
||||
error: "Error opening file".into(),
|
||||
msg: e.to_string(),
|
||||
@ -631,3 +638,16 @@ fn from_csv(
|
||||
df.cache_and_to_value(plugin, engine, call.head)
|
||||
}
|
||||
}
|
||||
|
||||
fn cloud_not_supported(file_type: PolarsFileType, span: Span) -> ShellError {
|
||||
ShellError::GenericError {
|
||||
error: format!(
|
||||
"Cloud operations not supported for file type {}",
|
||||
file_type.to_str()
|
||||
),
|
||||
msg: "".into(),
|
||||
span: Some(span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,12 @@ impl PolarsFileType {
|
||||
.collect::<Vec<&'static str>>()
|
||||
.join(", ");
|
||||
|
||||
ShellError::FileNotFoundCustom {
|
||||
msg: format!("Unsupported type {extension} expected {type_string}"),
|
||||
span,
|
||||
ShellError::GenericError {
|
||||
error: format!("Unsupported type {extension} expected {type_string}"),
|
||||
msg: "".into(),
|
||||
span: Some(span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user