mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:06:03 +02:00
Remove dfr from dataframe commands (#5760)
* input and output tests * input and output types for dfr * expression converter * remove deprecated command * correct expressions * cargo clippy * identifier for ls * cargo clippy * type for head and tail expression * modify full cell path if block
This commit is contained in:
@ -744,9 +744,54 @@ pub struct StateWorkingSet<'a> {
|
||||
pub permanent_state: &'a EngineState,
|
||||
pub delta: StateDelta,
|
||||
pub external_commands: Vec<Vec<u8>>,
|
||||
// Internal commands output that the next expression in the pipe will use to select a declaration
|
||||
// that matches the name in the found output
|
||||
pub found_outputs: Vec<Type>,
|
||||
pub type_scope: TypeScope,
|
||||
}
|
||||
|
||||
/// A temporary placeholder for expression types. It is used to keep track of the input types
|
||||
/// for each expression in a pipeline
|
||||
pub struct TypeScope {
|
||||
/// Layers that map the type inputs that are found in each parsed block
|
||||
outputs: Vec<Vec<Type>>,
|
||||
/// The last know output from a parsed block
|
||||
last_output: Type,
|
||||
}
|
||||
|
||||
impl Default for TypeScope {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
outputs: Vec::new(),
|
||||
last_output: Type::Any,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeScope {
|
||||
pub fn get_previous(&self) -> &Type {
|
||||
match self.outputs.last().and_then(|v| v.last()) {
|
||||
Some(input) => input,
|
||||
None => &Type::Any,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_last_output(&self) -> Type {
|
||||
self.last_output.clone()
|
||||
}
|
||||
|
||||
pub fn add_type(&mut self, input: Type) {
|
||||
match self.outputs.last_mut() {
|
||||
Some(v) => v.push(input),
|
||||
None => self.outputs.push(vec![input]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enter_scope(&mut self) {
|
||||
self.outputs.push(Vec::new())
|
||||
}
|
||||
|
||||
pub fn exit_scope(&mut self) -> Option<Vec<Type>> {
|
||||
self.last_output = self.get_previous().clone();
|
||||
self.outputs.pop()
|
||||
}
|
||||
}
|
||||
|
||||
/// A delta (or change set) between the current global state and a possible future global state. Deltas
|
||||
@ -871,7 +916,7 @@ impl<'a> StateWorkingSet<'a> {
|
||||
delta: StateDelta::new(permanent_state),
|
||||
permanent_state,
|
||||
external_commands: vec![],
|
||||
found_outputs: vec![],
|
||||
type_scope: TypeScope::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,10 @@ impl OverlayFrame {
|
||||
}
|
||||
|
||||
pub fn get_decl(&self, name: &[u8], input: &Type) -> Option<DeclId> {
|
||||
self.decls.get(&(name, input) as &dyn DeclKey).cloned()
|
||||
match self.decls.get(&(name, input) as &dyn DeclKey) {
|
||||
Some(decl) => Some(*decl),
|
||||
None => self.decls.get(&(name, &Type::Any) as &dyn DeclKey).cloned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ impl Display for Type {
|
||||
Type::Any => write!(f, "any"),
|
||||
Type::Error => write!(f, "error"),
|
||||
Type::Binary => write!(f, "binary"),
|
||||
Type::Custom(custom) => write!(f, "custom<{}>", custom),
|
||||
Type::Custom(custom) => write!(f, "{}", custom),
|
||||
Type::Signature => write!(f, "signature"),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user