From fe23858b6fe09e33b4a2730e8bf99e3249546cfb Mon Sep 17 00:00:00 2001 From: Wei <47681251+QuenKar@users.noreply.github.com> Date: Tue, 19 Sep 2023 16:26:25 +0800 Subject: [PATCH] fix: parse i64 to different kinds of timestamp (#2440) * feat: support i64 to multi-timestamp. * chore: fmt --- src/sql/src/statements.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/sql/src/statements.rs b/src/sql/src/statements.rs index 754c98a9f78e..cdb1c3c9ae5a 100644 --- a/src/sql/src/statements.rs +++ b/src/sql/src/statements.rs @@ -141,10 +141,15 @@ macro_rules! parse_number_to_value { Ok(Value::$Type($Target::from(n))) }, )+ - _ => ParseSqlValueSnafu { - msg: format!("Fail to parse number {}, invalid column type: {:?}", - $n, $data_type - )}.fail(), + ConcreteDataType::Timestamp(t) => { + let n = parse_sql_number::($n)?; + Ok(Value::Timestamp(Timestamp::new(n, t.unit()))) + }, + + _ => ParseSqlValueSnafu { + msg: format!("Fail to parse number {}, invalid column type: {:?}", + $n, $data_type + )}.fail(), } } } @@ -163,8 +168,7 @@ pub fn sql_number_to_value(data_type: &ConcreteDataType, n: &str) -> Result