diff --git a/datafusion/src/logical_plan/expr.rs b/datafusion/src/logical_plan/expr.rs index 2eee140f47fe..c3126980f4c3 100644 --- a/datafusion/src/logical_plan/expr.rs +++ b/datafusion/src/logical_plan/expr.rs @@ -30,7 +30,9 @@ use aggregates::{AccumulatorFunctionImplementation, StateTypeFunction}; use arrow::{compute::can_cast_types, datatypes::DataType}; use functions::{ReturnTypeFunction, ScalarFunctionImplementation, Signature}; use std::collections::{HashMap, HashSet}; +use std::convert::Infallible; use std::fmt; +use std::str::FromStr; use std::sync::Arc; /// A named reference to a qualified field in a schema. @@ -153,6 +155,14 @@ impl From<&str> for Column { } } +impl FromStr for Column { + type Err = Infallible; + + fn from_str(s: &str) -> std::result::Result { + Ok(s.into()) + } +} + impl fmt::Display for Column { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.relation { diff --git a/datafusion/src/scalar.rs b/datafusion/src/scalar.rs index e7354f8e62ec..ab0836424242 100644 --- a/datafusion/src/scalar.rs +++ b/datafusion/src/scalar.rs @@ -27,6 +27,8 @@ use arrow::{ TimestampSecondType, UInt16Type, UInt32Type, UInt64Type, UInt8Type, }, }; +use std::convert::Infallible; +use std::str::FromStr; use std::{convert::TryFrom, fmt, iter::repeat, sync::Arc}; /// Represents a dynamically typed, nullable single value. @@ -854,6 +856,14 @@ impl From<&str> for ScalarValue { } } +impl FromStr for ScalarValue { + type Err = Infallible; + + fn from_str(s: &str) -> std::result::Result { + Ok(s.into()) + } +} + macro_rules! impl_try_from { ($SCALAR:ident, $NATIVE:ident) => { impl TryFrom for $NATIVE {