fix: panic and interval when do not have keyword interval (#5339)

* fix: panic and interval when do not have keyword

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* fix: wrong pos...

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* fix: address comments drop the unreachable

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* fix: address comments and add sqlness tests

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
yihong
2025-01-15 14:42:24 +08:00
committed by GitHub
parent b64c075cdb
commit e56dd20426
4 changed files with 47 additions and 5 deletions

View File

@@ -132,6 +132,12 @@ pub enum Error {
#[snafu(implicit)]
location: Location,
},
#[snafu(display("ConcreteDataType not supported yet: {:?}", t))]
ConcreteTypeNotSupported {
t: ConcreteDataType,
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Failed to parse value: {}", msg))]
ParseSqlValue {
@@ -355,6 +361,7 @@ impl ErrorExt for Error {
| InvalidSql { .. }
| ParseSqlValue { .. }
| SqlTypeNotSupported { .. }
| ConcreteTypeNotSupported { .. }
| UnexpectedToken { .. }
| InvalidDefault { .. } => StatusCode::InvalidSyntax,

View File

@@ -136,9 +136,10 @@ fn parse_string_to_value(
let v = parse_string_to_vector_type_value(&s, Some(d.dim)).context(DatatypeSnafu)?;
Ok(Value::Binary(v.into()))
}
_ => {
unreachable!()
_ => ParseSqlValueSnafu {
msg: format!("Failed to parse {s} to {data_type} value"),
}
.fail(),
}
}
@@ -430,7 +431,13 @@ fn parse_column_default_constraint(
}
.fail();
}
_ => unreachable!(),
_ => {
return UnsupportedDefaultValueSnafu {
column_name,
expr: Expr::Value(SqlValue::Null),
}
.fail();
}
};
Ok(Some(default_constraint))
@@ -680,9 +687,10 @@ pub fn concrete_data_type_to_sql_data_type(data_type: &ConcreteDataType) -> Resu
ConcreteDataType::Duration(_)
| ConcreteDataType::Null(_)
| ConcreteDataType::List(_)
| ConcreteDataType::Dictionary(_) => {
unreachable!()
| ConcreteDataType::Dictionary(_) => error::ConcreteTypeNotSupportedSnafu {
t: data_type.clone(),
}
.fail(),
}
}