mirror of
https://github.com/nushell/nushell.git
synced 2025-05-09 12:34:26 +02:00
make polars commands propagate metadata
This commit is contained in:
parent
b8e6dde4ff
commit
c071e69f5a
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -3987,7 +3987,6 @@ dependencies = [
|
||||
"tempfile",
|
||||
"thiserror 2.0.6",
|
||||
"typetag",
|
||||
"url",
|
||||
"web-time",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
@ -7652,7 +7651,6 @@ dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -169,7 +169,7 @@ umask = "2.1"
|
||||
unicode-segmentation = "1.12"
|
||||
unicode-width = "0.2"
|
||||
ureq = { version = "2.12", default-features = false, features = ["socks-proxy"] }
|
||||
url = { version = "2.2", features = [ "serde" ] }
|
||||
url = "2.2"
|
||||
uu_cp = "0.0.30"
|
||||
uu_mkdir = "0.0.30"
|
||||
uu_mktemp = "0.0.30"
|
||||
|
@ -44,7 +44,6 @@ os_pipe = { workspace = true, optional = true, features = ["io_safety"] }
|
||||
log = { workspace = true }
|
||||
web-time = { workspace = true }
|
||||
memchr = { workspace = true }
|
||||
url = { workspace = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
nix = { workspace = true, default-features = false, features = ["signal"] }
|
||||
|
@ -1,5 +1,4 @@
|
||||
use std::path::PathBuf;
|
||||
use url::Url;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -35,7 +34,7 @@ pub enum DataSource {
|
||||
Ls,
|
||||
HtmlThemes,
|
||||
FilePath(PathBuf),
|
||||
Url(Box<Url>),
|
||||
Url(String),
|
||||
#[default]
|
||||
None,
|
||||
}
|
||||
|
@ -12,9 +12,8 @@ use nu_protocol::{
|
||||
shell_error::io::IoError, Category, DataSource, Example, LabeledError, PipelineData,
|
||||
PipelineMetadata, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
use std::{fs::File, io::BufReader, num::NonZeroUsize, path::PathBuf, str::FromStr, sync::Arc};
|
||||
use std::{fs::File, io::BufReader, num::NonZeroUsize, path::PathBuf, sync::Arc};
|
||||
|
||||
use polars::{
|
||||
lazy::frame::LazyJsonLineReader,
|
||||
@ -129,8 +128,8 @@ impl PluginCommand for OpenDataFrame {
|
||||
fn run(
|
||||
&self,
|
||||
plugin: &Self::Plugin,
|
||||
engine: &EngineInterface,
|
||||
call: &EvaluatedCall,
|
||||
engine: &nu_plugin::EngineInterface,
|
||||
call: &nu_plugin::EvaluatedCall,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
let metadata = input.metadata();
|
||||
@ -182,9 +181,7 @@ fn command(
|
||||
|
||||
let uri = spanned_file.item.clone();
|
||||
let data_source = if resource.cloud_options.is_some() {
|
||||
Url::from_str(&uri)
|
||||
.map(|url| DataSource::Url(url.into()))
|
||||
.unwrap_or_else(|_| DataSource::FilePath(uri.into()))
|
||||
DataSource::Url(uri)
|
||||
} else {
|
||||
DataSource::FilePath(uri.into())
|
||||
};
|
||||
|
@ -51,7 +51,7 @@ impl PluginCommand for CutSeries {
|
||||
engine: &EngineInterface,
|
||||
call: &EvaluatedCall,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
) -> Result<PipelineData, nu_protocol::LabeledError> {
|
||||
let metadata = input.metadata();
|
||||
self.run_inner(plugin, engine, call, input)
|
||||
.map(|pd| pd.set_metadata(metadata))
|
||||
|
@ -52,7 +52,7 @@ impl PluginCommand for QCutSeries {
|
||||
engine: &EngineInterface,
|
||||
call: &EvaluatedCall,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
) -> Result<PipelineData, nu_protocol::LabeledError> {
|
||||
let metadata = input.metadata();
|
||||
self.run_inner(plugin, engine, call, input)
|
||||
.map(|pd| pd.set_metadata(metadata))
|
||||
|
@ -88,6 +88,14 @@ impl PluginCommand for GetDay {
|
||||
self.run_inner(plugin, engine, call, input)
|
||||
.map(|pd| pd.set_metadata(metadata))
|
||||
}
|
||||
|
||||
fn extra_description(&self) -> &str {
|
||||
""
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
impl GetDay {
|
||||
@ -100,14 +108,6 @@ impl GetDay {
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
command(plugin, engine, call, input).map_err(LabeledError::from)
|
||||
}
|
||||
|
||||
fn extra_description(&self) -> &str {
|
||||
""
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
fn command(
|
||||
|
@ -154,6 +154,16 @@ impl PluginCommand for Truncate {
|
||||
self.run_inner(plugin, engine, call, input)
|
||||
.map(|pd| pd.set_metadata(metadata))
|
||||
}
|
||||
|
||||
fn extra_description(&self) -> &str {
|
||||
r#"Each date/datetime is mapped to the start of its bucket using the corresponding local datetime. Note that weekly buckets start on Monday. Ambiguous results are localised using the DST offset of the original timestamp - for example, truncating '2022-11-06 01:30:00 CST' by '1h' results in '2022-11-06 01:00:00 CST', whereas truncating '2022-11-06 01:30:00 CDT' by '1h' results in '2022-11-06 01:00:00 CDT'.
|
||||
|
||||
See Notes in documentation for full list of compatible string values for `every`: https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.dt.truncate.html"#
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
impl Truncate {
|
||||
@ -166,16 +176,6 @@ impl Truncate {
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
command(plugin, engine, call, input).map_err(LabeledError::from)
|
||||
}
|
||||
|
||||
fn extra_description(&self) -> &str {
|
||||
r#"Each date/datetime is mapped to the start of its bucket using the corresponding local datetime. Note that weekly buckets start on Monday. Ambiguous results are localised using the DST offset of the original timestamp - for example, truncating '2022-11-06 01:30:00 CST' by '1h' results in '2022-11-06 01:00:00 CST', whereas truncating '2022-11-06 01:30:00 CDT' by '1h' results in '2022-11-06 01:00:00 CDT'.
|
||||
|
||||
See Notes in documentation for full list of compatible string values for `every`: https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.dt.truncate.html"#
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
fn command(
|
||||
|
Loading…
Reference in New Issue
Block a user