Make polars save return an empty pipeline (#13833)

# Description
In order to be more consistent with it's nu counterpart, `polars save`
now returns an empty pipeline instead of a message of the saved file.

# User-Facing Changes
- `polars save` no longer displays a save message, making it consistent
with `save` behavior.
This commit is contained in:
Jack Wright 2024-09-12 04:23:40 -07:00 committed by GitHub
parent 1bcceafd93
commit fb34a4fc6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,7 +15,7 @@ use nu_path::expand_path_with;
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
use nu_protocol::{
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Spanned,
SyntaxShape, Type, Value,
SyntaxShape, Type,
};
use polars::error::PolarsError;
@ -209,12 +209,8 @@ fn command(
span: spanned_file.span,
}),
}?;
let file_value = Value::string(format!("saved {:?}", &file_path), file_span);
Ok(PipelineData::Value(
Value::list(vec![file_value], call.head),
None,
))
Ok(PipelineData::empty())
}
pub(crate) fn polars_file_save_error(e: PolarsError, span: Span) -> ShellError {
@ -264,16 +260,10 @@ pub(crate) mod test {
Span::test_data(),
),
);
let pipeline_data = plugin_test.eval(&cmd)?;
let _pipeline_data = plugin_test.eval(&cmd)?;
assert!(tmp_file.exists());
let value = pipeline_data.into_value(Span::test_data())?;
let list = value.as_list()?;
assert_eq!(list.len(), 1);
let msg = list.first().expect("should have a value").as_str()?;
assert!(msg.contains("saved"));
Ok(())
}
@ -290,19 +280,4 @@ pub(crate) mod test {
extension,
)
}
// #[test]
// pub fn test_to_ipc() -> Result<(), Box<dyn std::error::Error>> {
// test_sink("ipc")
// }
//
// #[test]
// pub fn test_to_csv() -> Result<(), Box<dyn std::error::Error>> {
// test_sink("csv")
// }
//
// #[test]
// pub fn test_to_json() -> Result<(), Box<dyn std::error::Error>> {
// test_sink("ndjson")
// }
}