diff --git a/src/sqlparser/src/parser_v2/data_type.rs b/src/sqlparser/src/parser_v2/data_type.rs index 2544e54d1d542..dff2d857c4953 100644 --- a/src/sqlparser/src/parser_v2/data_type.rs +++ b/src/sqlparser/src/parser_v2/data_type.rs @@ -208,10 +208,10 @@ fn keyword_datatype(input: &mut StatefulStream) -> PResult empty.value(DataType::Int), Keyword::BIGINT => empty.value(DataType::BigInt), Keyword::STRING | Keyword::VARCHAR => empty.value(DataType::Varchar), - Keyword::CHAR | Keyword::CHARACTER => dispatch! {keyword; - Keyword::VARYING => empty.value(DataType::Varchar), - _ => opt(precision_in_range(..)).map(DataType::Char), - }, + Keyword::CHAR | Keyword::CHARACTER => alt(( + Keyword::VARYING.value(DataType::Varchar), + opt(precision_in_range(..)).map(DataType::Char), + )), Keyword::UUID => empty.value(DataType::Uuid), Keyword::DATE => empty.value(DataType::Date), Keyword::TIMESTAMP => with_time_zone().map(DataType::Timestamp), diff --git a/src/sqlparser/tests/testdata/create.yaml b/src/sqlparser/tests/testdata/create.yaml index 9cfeefde1abc0..9d0378f89c661 100644 --- a/src/sqlparser/tests/testdata/create.yaml +++ b/src/sqlparser/tests/testdata/create.yaml @@ -13,6 +13,11 @@ formatted_ast: 'CreateSchema { schema_name: ObjectName([Ident { value: "t", quote_style: None }]), if_not_exists: true, user_specified: None }' - input: CREATE OR REPLACE TABLE t (a INT) formatted_sql: CREATE OR REPLACE TABLE t (a INT) +- input: CREATE OR REPLACE TABLE t (a CHAR AS) + error_msg: |- + sql parser error: expected an expression, found: ) + LINE 1: CREATE OR REPLACE TABLE t (a CHAR AS) + ^ - input: CREATE TABLE t (a INT, b INT) AS SELECT 1 AS b, 2 AS a formatted_sql: CREATE TABLE t (a INT, b INT) AS SELECT 1 AS b, 2 AS a - input: CREATE SOURCE src