Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions datafusion/src/logical_plan/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -153,6 +155,14 @@ impl From<&str> for Column {
}
}

impl FromStr for Column {
type Err = Infallible;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Ok(s.into())
}
}

impl fmt::Display for Column {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.relation {
Expand Down
10 changes: 10 additions & 0 deletions datafusion/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -854,6 +856,14 @@ impl From<&str> for ScalarValue {
}
}

impl FromStr for ScalarValue {
type Err = Infallible;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Ok(s.into())
}
}

macro_rules! impl_try_from {
($SCALAR:ident, $NATIVE:ident) => {
impl TryFrom<ScalarValue> for $NATIVE {
Expand Down