Skip to content
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

Cleanup text related #84

Closed
wants to merge 1 commit 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
7 changes: 0 additions & 7 deletions src/catalog/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ pub struct ColumnCatalog {
pub nullable: bool,
pub desc: ColumnDesc,
pub ref_expr: Option<ScalarExpression>,
// absoulte file path, used to store text content
pub text_files: Vec<String>,
pub deleted_text_files: Vec<String>,
}

impl ColumnCatalog {
Expand All @@ -35,8 +32,6 @@ impl ColumnCatalog {
nullable,
desc: column_desc,
ref_expr,
text_files: Vec::new(),
deleted_text_files: Vec::new(),
}
}

Expand All @@ -48,8 +43,6 @@ impl ColumnCatalog {
nullable: false,
desc: ColumnDesc::new(LogicalType::Varchar(None), false, false),
ref_expr: None,
text_files: Vec::new(),
deleted_text_files: Vec::new(),
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/execution/executor/dml/copy_from_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ mod tests {
nullable: false,
desc: ColumnDesc::new(LogicalType::Integer, true, false),
ref_expr: None,
text_files: vec![],
deleted_text_files: vec![],
}),
Arc::new(ColumnCatalog {
id: Some(1),
Expand All @@ -149,8 +147,6 @@ mod tests {
nullable: false,
desc: ColumnDesc::new(LogicalType::Float, false, false),
ref_expr: None,
text_files: vec![],
deleted_text_files: vec![],
}),
Arc::new(ColumnCatalog {
id: Some(1),
Expand All @@ -159,8 +155,6 @@ mod tests {
nullable: false,
desc: ColumnDesc::new(LogicalType::Varchar(Some(10)), false, false),
ref_expr: None,
text_files: vec![],
deleted_text_files: vec![],
}),
];

Expand Down
2 changes: 1 addition & 1 deletion src/execution/executor/dml/copy_to_file.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::planner::operator::copy_to_file::CopyToFileOperator;

#[warn(dead_code)]
#[allow(dead_code)]
pub struct CopyToFile {
op: CopyToFileOperator,
}
2 changes: 0 additions & 2 deletions src/expression/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,6 @@ mod test {
is_unique: false,
},
ref_expr: None,
text_files: Vec::new(),
deleted_text_files: Vec::new(),
});
let val_1 = Arc::new(DataValue::Int32(Some(1)));

Expand Down
4 changes: 0 additions & 4 deletions src/optimizer/rule/simplification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ mod test {
is_unique: false,
},
ref_expr: None,
text_files: Vec::new(),
deleted_text_files: Vec::new(),
};
let c2_col = ColumnCatalog {
id: Some(1),
Expand All @@ -161,8 +159,6 @@ mod test {
is_unique: true,
},
ref_expr: None,
text_files: Vec::new(),
deleted_text_files: Vec::new(),
};

// -(c1 + 1) > c2 => c1 < -c2 - 1
Expand Down
4 changes: 0 additions & 4 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub enum LogicalType {
Float,
Double,
Varchar(Option<u32>),
Text,
Date,
DateTime,
// decimal (precision, scale)
Expand Down Expand Up @@ -97,7 +96,6 @@ impl LogicalType {
LogicalType::Double => Some(8),
/// Note: The non-fixed length type's raw_len is None e.g. Varchar
LogicalType::Varchar(_) => None,
LogicalType::Text => None,
LogicalType::Decimal(_, _) => Some(16),
LogicalType::Date => Some(4),
LogicalType::DateTime => Some(8),
Expand Down Expand Up @@ -296,7 +294,6 @@ impl LogicalType {
LogicalType::Float => matches!(to, LogicalType::Double),
LogicalType::Double => false,
LogicalType::Varchar(_) => false,
LogicalType::Text => false,
LogicalType::Date => matches!(to, LogicalType::DateTime | LogicalType::Varchar(_)),
LogicalType::DateTime => matches!(to, LogicalType::Date | LogicalType::Varchar(_)),
LogicalType::Decimal(_, _) => false,
Expand All @@ -313,7 +310,6 @@ impl TryFrom<sqlparser::ast::DataType> for LogicalType {
sqlparser::ast::DataType::Char(len) | sqlparser::ast::DataType::Varchar(len) => {
Ok(LogicalType::Varchar(len.map(|len| len.length as u32)))
}
sqlparser::ast::DataType::Text => Ok(LogicalType::Text),
sqlparser::ast::DataType::Float(_) => Ok(LogicalType::Float),
sqlparser::ast::DataType::Double => Ok(LogicalType::Double),
sqlparser::ast::DataType::TinyInt(_) => Ok(LogicalType::Tinyint),
Expand Down
25 changes: 0 additions & 25 deletions src/types/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ impl DataValue {
LogicalType::Float => DataValue::Float32(None),
LogicalType::Double => DataValue::Float64(None),
LogicalType::Varchar(_) => DataValue::Utf8(None),
LogicalType::Text => DataValue::Utf8(None),
LogicalType::Date => DataValue::Date32(None),
LogicalType::DateTime => DataValue::Date64(None),
LogicalType::Decimal(_, _) => DataValue::Decimal(None),
Expand All @@ -352,7 +351,6 @@ impl DataValue {
LogicalType::Float => DataValue::Float32(Some(0.0)),
LogicalType::Double => DataValue::Float64(Some(0.0)),
LogicalType::Varchar(_) => DataValue::Utf8(Some("".to_string())),
LogicalType::Text => DataValue::Utf8(Some("".to_string())),
LogicalType::Date => DataValue::Date32(Some(UNIX_DATETIME.num_days_from_ce())),
LogicalType::DateTime => DataValue::Date64(Some(UNIX_DATETIME.timestamp())),
LogicalType::Decimal(_, _) => DataValue::Decimal(Some(Decimal::new(0, 0))),
Expand Down Expand Up @@ -423,9 +421,6 @@ impl DataValue {
LogicalType::Varchar(_) => DataValue::Utf8(
(!bytes.is_empty()).then(|| String::from_utf8(bytes.to_owned()).unwrap()),
),
LogicalType::Text => DataValue::Utf8(
(!bytes.is_empty()).then(|| String::from_utf8(bytes.to_owned()).unwrap()),
),
LogicalType::Date => {
DataValue::Date32((!bytes.is_empty()).then(|| i32::decode_fixed(bytes)))
}
Expand Down Expand Up @@ -599,7 +594,6 @@ impl DataValue {
LogicalType::Float => Ok(DataValue::Float32(None)),
LogicalType::Double => Ok(DataValue::Float64(None)),
LogicalType::Varchar(_) => Ok(DataValue::Utf8(None)),
LogicalType::Text => Ok(DataValue::Utf8(None)),
LogicalType::Date => Ok(DataValue::Date32(None)),
LogicalType::DateTime => Ok(DataValue::Date64(None)),
LogicalType::Decimal(_, _) => Ok(DataValue::Decimal(None)),
Expand All @@ -618,15 +612,13 @@ impl DataValue {
LogicalType::Float => Ok(DataValue::Float32(value.map(|v| v.into()))),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
_ => Err(TypeError::CastFail),
},
DataValue::Float32(value) => match to {
LogicalType::SqlNull => Ok(DataValue::Null),
LogicalType::Float => Ok(DataValue::Float32(value)),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(
value
.map(|v| {
Expand All @@ -643,7 +635,6 @@ impl DataValue {
LogicalType::SqlNull => Ok(DataValue::Null),
LogicalType::Double => Ok(DataValue::Float64(value)),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(
value
.map(|v| {
Expand Down Expand Up @@ -677,7 +668,6 @@ impl DataValue {
LogicalType::Float => Ok(DataValue::Float32(value.map(|v| v.into()))),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand Down Expand Up @@ -706,7 +696,6 @@ impl DataValue {
LogicalType::Float => Ok(DataValue::Float32(value.map(|v| v.into()))),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand All @@ -733,7 +722,6 @@ impl DataValue {
LogicalType::Bigint => Ok(DataValue::Int64(value.map(|v| v.into()))),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand All @@ -758,7 +746,6 @@ impl DataValue {
)),
LogicalType::Bigint => Ok(DataValue::Int64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand All @@ -779,7 +766,6 @@ impl DataValue {
LogicalType::Float => Ok(DataValue::Float32(value.map(|v| v.into()))),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand All @@ -798,7 +784,6 @@ impl DataValue {
LogicalType::Float => Ok(DataValue::Float32(value.map(|v| v.into()))),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand All @@ -814,7 +799,6 @@ impl DataValue {
LogicalType::UBigint => Ok(DataValue::UInt64(value.map(|v| v.into()))),
LogicalType::Double => Ok(DataValue::Float64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand All @@ -827,7 +811,6 @@ impl DataValue {
LogicalType::SqlNull => Ok(DataValue::Null),
LogicalType::UBigint => Ok(DataValue::UInt64(value.map(|v| v.into()))),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Decimal(_, option) => Ok(DataValue::Decimal(value.map(|v| {
let mut decimal = Decimal::from(v);
Self::decimal_round_i(option, &mut decimal);
Expand Down Expand Up @@ -873,7 +856,6 @@ impl DataValue {
value.map(|v| f64::from_str(&v)).transpose()?,
)),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
LogicalType::Date => {
let option = value
.map(|v| {
Expand Down Expand Up @@ -905,9 +887,6 @@ impl DataValue {
DataValue::Date32(value) => match to {
LogicalType::SqlNull => Ok(DataValue::Null),
LogicalType::Varchar(len) => varchar_cast!(Self::format_date(value), len),
LogicalType::Text => Ok(DataValue::Utf8(
Self::format_date(value).map(|v| format!("{v}")),
)),
LogicalType::Date => Ok(DataValue::Date32(value)),
LogicalType::DateTime => {
let option = value.and_then(|v| {
Expand All @@ -923,9 +902,6 @@ impl DataValue {
DataValue::Date64(value) => match to {
LogicalType::SqlNull => Ok(DataValue::Null),
LogicalType::Varchar(len) => varchar_cast!(Self::format_datetime(value), len),
LogicalType::Text => Ok(DataValue::Utf8(
Self::format_datetime(value).map(|v| format!("{v}")),
)),
LogicalType::Date => {
let option = value.and_then(|v| {
NaiveDateTime::from_timestamp_opt(v, 0)
Expand All @@ -941,7 +917,6 @@ impl DataValue {
LogicalType::SqlNull => Ok(DataValue::Null),
LogicalType::Decimal(_, _) => Ok(DataValue::Decimal(value)),
LogicalType::Varchar(len) => varchar_cast!(value, len),
LogicalType::Text => Ok(DataValue::Utf8(value.map(|v| format!("{v}")))),
_ => Err(TypeError::CastFail),
},
}
Expand Down
Loading