Skip to content

Draft: LogicalScalar #14609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
25 changes: 13 additions & 12 deletions datafusion/common/src/param_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
// under the License.

use crate::error::{_plan_datafusion_err, _plan_err};
use crate::{Result, ScalarValue};
use crate::scalar::LogicalScalar;
use crate::Result;
use arrow::datatypes::DataType;
use std::collections::HashMap;

/// The parameter value corresponding to the placeholder
#[derive(Debug, Clone)]
pub enum ParamValues {
/// For positional query parameters, like `SELECT * FROM test WHERE a > $1 AND b = $2`
List(Vec<ScalarValue>),
List(Vec<LogicalScalar>),
/// For named query parameters, like `SELECT * FROM test WHERE a > $foo AND b = $goo`
Map(HashMap<String, ScalarValue>),
Map(HashMap<String, LogicalScalar>),
}

impl ParamValues {
Expand Down Expand Up @@ -65,7 +66,7 @@ impl ParamValues {
}
}

pub fn get_placeholders_with_values(&self, id: &str) -> Result<ScalarValue> {
pub fn get_placeholders_with_values(&self, id: &str) -> Result<LogicalScalar> {
match self {
ParamValues::List(list) => {
if id.is_empty() {
Expand Down Expand Up @@ -97,29 +98,29 @@ impl ParamValues {
}
}

impl From<Vec<ScalarValue>> for ParamValues {
fn from(value: Vec<ScalarValue>) -> Self {
impl From<Vec<LogicalScalar>> for ParamValues {
fn from(value: Vec<LogicalScalar>) -> Self {
Self::List(value)
}
}

impl<K> From<Vec<(K, ScalarValue)>> for ParamValues
impl<K> From<Vec<(K, LogicalScalar)>> for ParamValues
where
K: Into<String>,
{
fn from(value: Vec<(K, ScalarValue)>) -> Self {
let value: HashMap<String, ScalarValue> =
fn from(value: Vec<(K, LogicalScalar)>) -> Self {
let value: HashMap<String, LogicalScalar> =
value.into_iter().map(|(k, v)| (k.into(), v)).collect();
Self::Map(value)
}
}

impl<K> From<HashMap<K, ScalarValue>> for ParamValues
impl<K> From<HashMap<K, LogicalScalar>> for ParamValues
where
K: Into<String>,
{
fn from(value: HashMap<K, ScalarValue>) -> Self {
let value: HashMap<String, ScalarValue> =
fn from(value: HashMap<K, LogicalScalar>) -> Self {
let value: HashMap<String, LogicalScalar> =
value.into_iter().map(|(k, v)| (k.into(), v)).collect();
Self::Map(value)
}
Expand Down
Loading
Loading