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
2 changes: 1 addition & 1 deletion examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ implement_from_tuple!(
}
},
c2: String => |inner: &mut MyStruct, value| {
if let DataValue::Utf8(Some(val)) = value {
if let DataValue::Utf8 { value: Some(val), .. } = value {
inner.c2 = val;
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/binder/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::expression::function::{FunctionSummary, ScalarFunction};
use crate::expression::{AliasType, ScalarExpression};
use crate::planner::LogicalPlan;
use crate::storage::Transaction;
use crate::types::value::DataValue;
use crate::types::value::{DataValue, Utf8Type};
use crate::types::LogicalType;

macro_rules! try_alias {
Expand Down Expand Up @@ -67,7 +67,11 @@ impl<'a, T: Transaction> Binder<'a, T> {
} => self.bind_cast(expr, data_type),
Expr::TypedString { data_type, value } => {
let logical_type = LogicalType::try_from(data_type.clone())?;
let value = DataValue::Utf8(Some(value.to_string())).cast(&logical_type)?;
let value = DataValue::Utf8 {
value: Some(value.to_string()),
ty: Utf8Type::Variable,
}
.cast(&logical_type)?;

Ok(ScalarExpression::Constant(Arc::new(value)))
}
Expand Down Expand Up @@ -597,6 +601,9 @@ impl<'a, T: Transaction> Binder<'a, T> {
}

fn wildcard_expr() -> ScalarExpression {
ScalarExpression::Constant(Arc::new(DataValue::Utf8(Some("*".to_string()))))
ScalarExpression::Constant(Arc::new(DataValue::Utf8 {
value: Some("*".to_string()),
ty: Utf8Type::Variable,
}))
}
}
7 changes: 5 additions & 2 deletions src/execution/volcano/dml/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::planner::LogicalPlan;
use crate::storage::Transaction;
use crate::types::index::IndexMetaRef;
use crate::types::tuple::Tuple;
use crate::types::value::DataValue;
use crate::types::value::{DataValue, Utf8Type};
use futures_async_stream::try_stream;
use itertools::Itertools;
use std::fmt::Formatter;
Expand Down Expand Up @@ -106,7 +106,10 @@ impl Analyze {
let meta = StatisticsMeta::new(histogram, sketch);

meta.to_file(&path)?;
values.push(Arc::new(DataValue::Utf8(Some(path.clone()))));
values.push(Arc::new(DataValue::Utf8 {
value: Some(path.clone()),
ty: Utf8Type::Variable,
}));
transaction.save_table_meta(&table_name, path, meta)?;
}
yield Tuple { id: None, values };
Expand Down
48 changes: 33 additions & 15 deletions src/execution/volcano/dql/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@ use crate::execution::volcano::{BoxedExecutor, ReadExecutor};
use crate::planner::operator::describe::DescribeOperator;
use crate::storage::Transaction;
use crate::types::tuple::Tuple;
use crate::types::value::{DataValue, ValueRef};
use crate::types::value::{DataValue, Utf8Type, ValueRef};
use futures_async_stream::try_stream;
use lazy_static::lazy_static;
use std::sync::Arc;

lazy_static! {
static ref PRIMARY_KEY_TYPE: ValueRef =
Arc::new(DataValue::Utf8(Some(String::from("PRIMARY"))));
static ref UNIQUE_KEY_TYPE: ValueRef = Arc::new(DataValue::Utf8(Some(String::from("UNIQUE"))));
static ref EMPTY_KEY_TYPE: ValueRef = Arc::new(DataValue::Utf8(Some(String::from("EMPTY"))));
static ref PRIMARY_KEY_TYPE: ValueRef = Arc::new(DataValue::Utf8 {
value: Some(String::from("PRIMARY")),
ty: Utf8Type::Variable
});
static ref UNIQUE_KEY_TYPE: ValueRef = Arc::new(DataValue::Utf8 {
value: Some(String::from("UNIQUE")),
ty: Utf8Type::Variable
});
static ref EMPTY_KEY_TYPE: ValueRef = Arc::new(DataValue::Utf8 {
value: Some(String::from("EMPTY")),
ty: Utf8Type::Variable
});
}

pub struct Describe {
Expand Down Expand Up @@ -59,17 +67,27 @@ impl Describe {
.map(|expr| format!("{}", expr))
.unwrap_or_else(|| "null".to_string());
let values = vec![
Arc::new(DataValue::Utf8(Some(column.name().to_string()))),
Arc::new(DataValue::Utf8(Some(datatype.to_string()))),
Arc::new(DataValue::Utf8(Some(
datatype
.raw_len()
.map(|len| len.to_string())
.unwrap_or_else(|| "DYNAMIC".to_string()),
))),
Arc::new(DataValue::Utf8(Some(column.nullable.to_string()))),
Arc::new(DataValue::Utf8 {
value: Some(column.name().to_string()),
ty: Utf8Type::Variable,
}),
Arc::new(DataValue::Utf8 {
value: Some(datatype.to_string()),
ty: Utf8Type::Variable,
}),
Arc::new(DataValue::Utf8 {
value: datatype.raw_len().map(|len| len.to_string()),
ty: Utf8Type::Variable,
}),
Arc::new(DataValue::Utf8 {
value: Some(column.nullable.to_string()),
ty: Utf8Type::Variable,
}),
key_fn(column),
Arc::new(DataValue::Utf8(Some(default))),
Arc::new(DataValue::Utf8 {
value: Some(default),
ty: Utf8Type::Variable,
}),
];
yield Tuple { id: None, values };
}
Expand Down
7 changes: 5 additions & 2 deletions src/execution/volcano/dql/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::execution::volcano::{BoxedExecutor, ReadExecutor};
use crate::planner::LogicalPlan;
use crate::storage::Transaction;
use crate::types::tuple::Tuple;
use crate::types::value::DataValue;
use crate::types::value::{DataValue, Utf8Type};
use futures_async_stream::try_stream;
use std::sync::Arc;

Expand All @@ -26,7 +26,10 @@ impl<T: Transaction> ReadExecutor<T> for Explain {
impl Explain {
#[try_stream(boxed, ok = Tuple, error = DatabaseError)]
pub async fn _execute(self) {
let values = vec![Arc::new(DataValue::Utf8(Some(self.plan.explain(0))))];
let values = vec![Arc::new(DataValue::Utf8 {
value: Some(self.plan.explain(0)),
ty: Utf8Type::Variable,
})];

yield Tuple { id: None, values };
}
Expand Down
7 changes: 5 additions & 2 deletions src/execution/volcano/dql/show_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::errors::DatabaseError;
use crate::execution::volcano::{BoxedExecutor, ReadExecutor};
use crate::storage::Transaction;
use crate::types::tuple::Tuple;
use crate::types::value::DataValue;
use crate::types::value::{DataValue, Utf8Type};
use futures_async_stream::try_stream;
use std::sync::Arc;

Expand All @@ -21,7 +21,10 @@ impl ShowTables {
let metas = transaction.table_metas()?;

for TableMeta { table_name } in metas {
let values = vec![Arc::new(DataValue::Utf8(Some(table_name.to_string())))];
let values = vec![Arc::new(DataValue::Utf8 {
value: Some(table_name.to_string()),
ty: Utf8Type::Variable,
})];

yield Tuple { id: None, values };
}
Expand Down
22 changes: 17 additions & 5 deletions src/expression/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::errors::DatabaseError;
use crate::expression::function::ScalarFunction;
use crate::expression::{AliasType, BinaryOperator, ScalarExpression};
use crate::types::tuple::Tuple;
use crate::types::value::{DataValue, ValueRef};
use crate::types::value::{DataValue, Utf8Type, ValueRef};
use crate::types::LogicalType;
use itertools::Itertools;
use lazy_static::lazy_static;
Expand All @@ -23,7 +23,10 @@ macro_rules! eval_to_num {
{
num_i32
} else {
return Ok(Arc::new(DataValue::Utf8(None)));
return Ok(Arc::new(DataValue::Utf8 {
value: None,
ty: Utf8Type::Variable,
}));
}
};
}
Expand Down Expand Up @@ -164,7 +167,10 @@ impl ScalarExpression {
from += len_i + 1;
}
if from > len_i {
return Ok(Arc::new(DataValue::Utf8(None)));
return Ok(Arc::new(DataValue::Utf8 {
value: None,
ty: Utf8Type::Variable,
}));
}
string = string.split_off(from as usize);
}
Expand All @@ -174,9 +180,15 @@ impl ScalarExpression {
let _ = string.split_off(for_i);
}

Ok(Arc::new(DataValue::Utf8(Some(string))))
Ok(Arc::new(DataValue::Utf8 {
value: Some(string),
ty: Utf8Type::Variable,
}))
} else {
Ok(Arc::new(DataValue::Utf8(None)))
Ok(Arc::new(DataValue::Utf8 {
value: None,
ty: Utf8Type::Variable,
}))
}
}
ScalarExpression::Position { expr, in_expr } => {
Expand Down
Loading