Skip to content

Commit

Permalink
Support INTEGER again in addition to INT in CREATE TABLE and `C…
Browse files Browse the repository at this point in the history
…AST` statements (#3167)

* Update test to fail with INTEGER

* Fix error

* List all unsupported types
  • Loading branch information
alamb committed Aug 16, 2022
1 parent 8e9a8d5 commit 89bcfc4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datafusion/core/tests/sql/mod.rs
Expand Up @@ -631,7 +631,7 @@ async fn register_aggregate_csv_by_sql(ctx: &SessionContext) {
c2 INT NOT NULL,
c3 SMALLINT NOT NULL,
c4 SMALLINT NOT NULL,
c5 INT NOT NULL,
c5 INTEGER NOT NULL,
c6 BIGINT NOT NULL,
c7 SMALLINT NOT NULL,
c8 INT NOT NULL,
Expand Down
27 changes: 25 additions & 2 deletions datafusion/sql/src/planner.rs
Expand Up @@ -483,7 +483,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
fn make_data_type(&self, sql_type: &SQLDataType) -> Result<DataType> {
match sql_type {
SQLDataType::BigInt(_) => Ok(DataType::Int64),
SQLDataType::Int(_) => Ok(DataType::Int32),
SQLDataType::Int(_) | SQLDataType::Integer(_) => Ok(DataType::Int32),
SQLDataType::SmallInt(_) => Ok(DataType::Int16),
SQLDataType::Char(_) | SQLDataType::Varchar(_) | SQLDataType::Text => {
Ok(DataType::Utf8)
Expand All @@ -498,7 +498,30 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
SQLDataType::Date => Ok(DataType::Date32),
SQLDataType::Time => Ok(DataType::Time64(TimeUnit::Nanosecond)),
SQLDataType::Timestamp => Ok(DataType::Timestamp(TimeUnit::Nanosecond, None)),
_ => Err(DataFusionError::NotImplemented(format!(
// Explicitly list all other types so that if sqlparser
// adds/changes the `SQLDataType` the compiler will tell us on upgrade
// and avoid bugs like https://github.com/apache/arrow-datafusion/issues/3059
SQLDataType::Nvarchar(_)
| SQLDataType::Uuid
| SQLDataType::Binary(_)
| SQLDataType::Varbinary(_)
| SQLDataType::Blob(_)
| SQLDataType::TinyInt(_)
| SQLDataType::UnsignedTinyInt(_)
| SQLDataType::UnsignedSmallInt(_)
| SQLDataType::UnsignedInt(_)
| SQLDataType::UnsignedInteger(_)
| SQLDataType::UnsignedBigInt(_)
| SQLDataType::Datetime
| SQLDataType::Interval
| SQLDataType::Regclass
| SQLDataType::String
| SQLDataType::Bytea
| SQLDataType::Custom(_)
| SQLDataType::Array(_)
| SQLDataType::Enum(_)
| SQLDataType::Set(_)
| SQLDataType::Clob(_) => Err(DataFusionError::NotImplemented(format!(
"The SQL data type {:?} is not implemented",
sql_type
))),
Expand Down

0 comments on commit 89bcfc4

Please sign in to comment.