mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-03 20:02:54 +00:00
feat: alias for boolean (#5639)
This commit is contained in:
@@ -167,6 +167,7 @@ pub(crate) fn get_type_by_alias(data_type: &DataType) -> Option<DataType> {
|
||||
DataType::UInt64 => Some(DataType::UnsignedBigInt(None)),
|
||||
DataType::Float32 => Some(DataType::Float(None)),
|
||||
DataType::Float64 => Some(DataType::Double),
|
||||
DataType::Bool => Some(DataType::Boolean),
|
||||
DataType::Datetime(_) => Some(DataType::Timestamp(Some(6), TimezoneInfo::None)),
|
||||
_ => None,
|
||||
}
|
||||
@@ -343,6 +344,20 @@ mod tests {
|
||||
test_timestamp_alias(&format!("Timestamp({precision})"), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_boolean_alias() {
|
||||
let sql = "CREATE TABLE test(b bool, ts TIMESTAMP TIME INDEX)";
|
||||
let mut stmts =
|
||||
ParserContext::create_with_dialect(sql, &GenericDialect {}, ParseOptions::default())
|
||||
.unwrap();
|
||||
transform_statements(&mut stmts).unwrap();
|
||||
|
||||
match &stmts[0] {
|
||||
Statement::CreateTable(c) => assert_eq!("CREATE TABLE test (\n b BOOLEAN,\n ts TIMESTAMP NOT NULL,\n TIME INDEX (ts)\n)\nENGINE=mito\n", c.to_string()),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transform_timestamp_alias() {
|
||||
// Timestamp[Second | Millisecond | Microsecond | Nanosecond]
|
||||
|
||||
Reference in New Issue
Block a user