Skip to content

Allow to customize convert_data_type behavior when SQL planning #13292

@goldmedal

Description

@goldmedal

Is your feature request related to a problem or challenge?

In datafusion-sqlparser-rs, we define many SQL types but they aren't all required by the DataFusion core.

// 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/datafusion/issues/3059
SQLDataType::Nvarchar(_)
| SQLDataType::JSON
| SQLDataType::Uuid

I think it's good to provide a way to extend or customize the behavior for SQL type to DataFusion type (maybe changed to NativeType in the future) for the downstream project that may want to use those unsupported SQL types.

Describe the solution you'd like

Introduce a new API for ExprPlanner,

    /// Plan SQL type to DataFusion data type
    ///
    /// Returns None if not possible
    fn plan_data_type(&self, _sql_type: &ast::DataType) -> Option<DataType> {
        None
    }

Try planning the SQL type using ExprPlanner first. If not present, revert to the default behavior.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions