Skip to content

Commit 6199b76

Browse files
committed
invalid: fix name Date -> DateTime
1 parent ab7ed9b commit 6199b76

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/expression/value_compute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ pub fn binary_op(
726726
LogicalType::SqlNull => {
727727
DataValue::Boolean(None)
728728
}
729-
LogicalType::Date => {
729+
LogicalType::DateTime => {
730730
let left_value = unpack_date(left.clone().cast(&unified_type));
731731
let right_value = unpack_date(right.clone().cast(&unified_type));
732732

src/types/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub enum LogicalType {
5555
Float,
5656
Double,
5757
Varchar,
58-
Date,
58+
DateTime,
5959
}
6060

6161
impl LogicalType {
@@ -75,7 +75,7 @@ impl LogicalType {
7575
LogicalType::Float => Some(4),
7676
LogicalType::Double => Some(8),
7777
LogicalType::Varchar => None,
78-
LogicalType::Date => Some(8),
78+
LogicalType::DateTime => Some(8),
7979
}
8080
}
8181

@@ -146,8 +146,8 @@ impl LogicalType {
146146
if left.is_numeric() && right.is_numeric() {
147147
return LogicalType::combine_numeric_types(left, right);
148148
}
149-
if matches!((left, right), (LogicalType::Date, LogicalType::Varchar) | (LogicalType::Varchar, LogicalType::Date)) {
150-
return Ok(LogicalType::Date);
149+
if matches!((left, right), (LogicalType::DateTime, LogicalType::Varchar) | (LogicalType::Varchar, LogicalType::DateTime)) {
150+
return Ok(LogicalType::DateTime);
151151
}
152152
Err(TypeError::InternalError(format!(
153153
"can not compare two types: {:?} and {:?}",
@@ -250,7 +250,7 @@ impl LogicalType {
250250
LogicalType::Float => matches!(to, LogicalType::Double),
251251
LogicalType::Double => false,
252252
LogicalType::Varchar => false,
253-
LogicalType::Date => false,
253+
LogicalType::DateTime => false,
254254
}
255255
}
256256
}
@@ -280,7 +280,7 @@ impl TryFrom<sqlparser::ast::DataType> for LogicalType {
280280
sqlparser::ast::DataType::BigInt(_) => Ok(LogicalType::Bigint),
281281
sqlparser::ast::DataType::UnsignedBigInt(_) => Ok(LogicalType::UBigint),
282282
sqlparser::ast::DataType::Boolean => Ok(LogicalType::Boolean),
283-
sqlparser::ast::DataType::Datetime(_) => Ok(LogicalType::Date),
283+
sqlparser::ast::DataType::Datetime(_) => Ok(LogicalType::DateTime),
284284
other => Err(TypeError::NotImplementedSqlparserDataType(
285285
other.to_string(),
286286
)),

src/types/tuple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ mod tests {
168168
Arc::new(ColumnCatalog::new(
169169
"c11".to_string(),
170170
false,
171-
ColumnDesc::new(LogicalType::Date, false)
171+
ColumnDesc::new(LogicalType::DateTime, false)
172172
)),
173173
];
174174

src/types/value.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl DataValue {
200200
LogicalType::Float => DataValue::Float32(None),
201201
LogicalType::Double => DataValue::Float64(None),
202202
LogicalType::Varchar => DataValue::Utf8(None),
203-
LogicalType::Date => DataValue::Date64(None)
203+
LogicalType::DateTime => DataValue::Date64(None)
204204
}
205205
}
206206

@@ -220,7 +220,7 @@ impl DataValue {
220220
LogicalType::Float => DataValue::Float32(Some(0.0)),
221221
LogicalType::Double => DataValue::Float64(Some(0.0)),
222222
LogicalType::Varchar => DataValue::Utf8(Some("".to_string())),
223-
LogicalType::Date => DataValue::Date64(Some(UNIX_DATETIME.timestamp()))
223+
LogicalType::DateTime => DataValue::Date64(Some(UNIX_DATETIME.timestamp()))
224224
}
225225
}
226226

@@ -267,7 +267,7 @@ impl DataValue {
267267
f64::from_ne_bytes(buf)
268268
})),
269269
LogicalType::Varchar => DataValue::Utf8((!bytes.is_empty()).then(|| String::from_utf8(bytes.to_owned()).unwrap())),
270-
LogicalType::Date => DataValue::Date64((!bytes.is_empty()).then(|| i64::decode_fixed(bytes))),
270+
LogicalType::DateTime => DataValue::Date64((!bytes.is_empty()).then(|| i64::decode_fixed(bytes))),
271271
}
272272
}
273273

@@ -286,7 +286,7 @@ impl DataValue {
286286
DataValue::UInt32(_) => LogicalType::UInteger,
287287
DataValue::UInt64(_) => LogicalType::UBigint,
288288
DataValue::Utf8(_) => LogicalType::Varchar,
289-
DataValue::Date64(_) => LogicalType::Date,
289+
DataValue::Date64(_) => LogicalType::DateTime,
290290
}
291291
}
292292

@@ -308,7 +308,7 @@ impl DataValue {
308308
LogicalType::Float => DataValue::Float32(None),
309309
LogicalType::Double => DataValue::Float64(None),
310310
LogicalType::Varchar => DataValue::Utf8(None),
311-
LogicalType::Date => DataValue::Date64(None),
311+
LogicalType::DateTime => DataValue::Date64(None),
312312
}
313313
}
314314
DataValue::Boolean(value) => {
@@ -327,7 +327,7 @@ impl DataValue {
327327
LogicalType::Float => DataValue::Float32(value.map(|v| v.into())),
328328
LogicalType::Double => DataValue::Float64(value.map(|v| v.into())),
329329
LogicalType::Varchar => DataValue::Utf8(value.map(|v| format!("{}", v))),
330-
LogicalType::Date => panic!("not support"),
330+
LogicalType::DateTime => panic!("not support"),
331331
}
332332
}
333333
DataValue::Float32(value) => {
@@ -481,7 +481,7 @@ impl DataValue {
481481
LogicalType::Float => DataValue::Float32(value.map(|v| f32::from_str(&v).unwrap())),
482482
LogicalType::Double => DataValue::Float64(value.map(|v| f64::from_str(&v).unwrap())),
483483
LogicalType::Varchar => DataValue::Utf8(value),
484-
LogicalType::Date => {
484+
LogicalType::DateTime => {
485485
let option = value.map(|v| {
486486
NaiveDateTime::parse_from_str(&v, "%Y-%m-%d %H:%M:%S")
487487
.unwrap()
@@ -497,7 +497,7 @@ impl DataValue {
497497
LogicalType::Invalid => panic!("invalid logical type"),
498498
LogicalType::SqlNull => DataValue::Null,
499499
LogicalType::Varchar => DataValue::Utf8(value.map(|v| format!("{}", v))),
500-
LogicalType::Date => DataValue::Date64(value),
500+
LogicalType::DateTime => DataValue::Date64(value),
501501
_ => panic!("not support"),
502502
}
503503
}

0 commit comments

Comments
 (0)