Skip to content

Commit 8cf1549

Browse files
authored
Merge 62ba0d4 into 36def8f
2 parents 36def8f + 62ba0d4 commit 8cf1549

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎datafusion/core/tests/sql/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ async fn register_aggregate_csv_by_sql(ctx: &SessionContext) {
631631
c2 INT NOT NULL,
632632
c3 SMALLINT NOT NULL,
633633
c4 SMALLINT NOT NULL,
634-
c5 INT NOT NULL,
634+
c5 INTEGER NOT NULL,
635635
c6 BIGINT NOT NULL,
636636
c7 SMALLINT NOT NULL,
637637
c8 INT NOT NULL,

‎datafusion/sql/src/planner.rs‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
483483
fn make_data_type(&self, sql_type: &SQLDataType) -> Result<DataType> {
484484
match sql_type {
485485
SQLDataType::BigInt(_) => Ok(DataType::Int64),
486-
SQLDataType::Int(_) => Ok(DataType::Int32),
486+
SQLDataType::Int(_) | SQLDataType::Integer(_) => Ok(DataType::Int32),
487487
SQLDataType::SmallInt(_) => Ok(DataType::Int16),
488488
SQLDataType::Char(_) | SQLDataType::Varchar(_) | SQLDataType::Text => {
489489
Ok(DataType::Utf8)
@@ -498,7 +498,30 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
498498
SQLDataType::Date => Ok(DataType::Date32),
499499
SQLDataType::Time => Ok(DataType::Time64(TimeUnit::Nanosecond)),
500500
SQLDataType::Timestamp => Ok(DataType::Timestamp(TimeUnit::Nanosecond, None)),
501-
_ => Err(DataFusionError::NotImplemented(format!(
501+
// Explicitly list all other types so that if sqlparser
502+
// adds/changes the `SQLDataType` the compiler will tell us on upgrade
503+
// and avoid bugs like https://github.com/apache/arrow-datafusion/issues/3059
504+
SQLDataType::Nvarchar(_)
505+
| SQLDataType::Uuid
506+
| SQLDataType::Binary(_)
507+
| SQLDataType::Varbinary(_)
508+
| SQLDataType::Blob(_)
509+
| SQLDataType::TinyInt(_)
510+
| SQLDataType::UnsignedTinyInt(_)
511+
| SQLDataType::UnsignedSmallInt(_)
512+
| SQLDataType::UnsignedInt(_)
513+
| SQLDataType::UnsignedInteger(_)
514+
| SQLDataType::UnsignedBigInt(_)
515+
| SQLDataType::Datetime
516+
| SQLDataType::Interval
517+
| SQLDataType::Regclass
518+
| SQLDataType::String
519+
| SQLDataType::Bytea
520+
| SQLDataType::Custom(_)
521+
| SQLDataType::Array(_)
522+
| SQLDataType::Enum(_)
523+
| SQLDataType::Set(_)
524+
| SQLDataType::Clob(_) => Err(DataFusionError::NotImplemented(format!(
502525
"The SQL data type {:?} is not implemented",
503526
sql_type
504527
))),

0 commit comments

Comments
 (0)