Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fuzz/fuzz_seeds/duckdb_2948_uinteger.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT 1::UINTEGER;
5 changes: 5 additions & 0 deletions src/ast/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ pub enum DataType {
Int4Unsigned(Option<u64>),
/// Unsigned integer with optional display width, e.g. INTEGER UNSIGNED or INTEGER(11) UNSIGNED.
IntegerUnsigned(Option<u64>),
/// Unsigned integer, e.g. UINTEGER.
UInteger,
/// 128-bit integer type, e.g. HUGEINT.
HugeInt,
/// Unsigned 128-bit integer type, e.g. UHUGEINT.
Expand Down Expand Up @@ -689,6 +691,9 @@ impl fmt::Display for DataType {
DataType::USmallInt => {
write!(f, "USMALLINT")
}
DataType::UInteger => {
write!(f, "UINTEGER")
}
DataType::UBigInt => {
write!(f, "UBIGINT")
}
Expand Down
1 change: 1 addition & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ define_keywords!(
UINT32,
UINT64,
UINT8,
UINTEGER,
UNBOUNDED,
UNCACHE,
UNCOMMITTED,
Expand Down
1 change: 1 addition & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13817,6 +13817,7 @@ impl<'a> Parser<'a> {
Keyword::HUGEINT => Ok(DataType::HugeInt),
Keyword::UBIGINT => Ok(DataType::UBigInt),
Keyword::UHUGEINT => Ok(DataType::UHugeInt),
Keyword::UINTEGER => Ok(DataType::UInteger),
Keyword::USMALLINT => Ok(DataType::USmallInt),
Keyword::UTINYINT => Ok(DataType::UTinyInt),
Keyword::UINT8 => Ok(DataType::UInt8),
Expand Down
22 changes: 22 additions & 0 deletions tests/sqlparser_duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ fn test_duckdb_specific_int_types() {
let duckdb_dtypes = vec![
("UTINYINT", DataType::UTinyInt),
("USMALLINT", DataType::USmallInt),
("UINTEGER", DataType::UInteger),
("UBIGINT", DataType::UBigInt),
("UHUGEINT", DataType::UHugeInt),
("HUGEINT", DataType::HugeInt),
Expand Down Expand Up @@ -976,3 +977,24 @@ fn display_create_macro_propagates_argument_list_errors() {
}
}
}

#[test]
fn parse_create_table_with_uinteger_column() {
let sql = "CREATE TABLE t (uinteger UINTEGER)";
match duckdb_and_generic().verified_stmt(sql) {
Statement::CreateTable(CreateTable { columns, .. }) => {
assert_eq!(columns[0].name.value, "uinteger");
assert_eq!(columns[0].data_type, DataType::UInteger);
}
statement => panic!("unexpected statement: {statement:?}"),
}

assert_eq!(
duckdb_and_generic()
.parse_sql_statements("CREATE TABLE t (c UINTEGER(10))")
.unwrap_err(),
ParserError::ParserError(
"Expected: ',' or ')' after column definition, found: (".to_string()
)
);
}
Loading