Skip to content
Merged
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
2 changes: 1 addition & 1 deletion datafusion/core/tests/sql/mod.rs
Original file line number Diff line number Diff line change
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this change, many of the sql_integration tests fail

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
Original file line number Diff line number Diff line change
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),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the fix

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not change the behavior, but makes the current behavior more explicit in my opinion

It also makes clear some surprising things (like several unsigned variants appear not to be supported along with interval as noted by @waitingkuo in #3166 (comment)

// 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