Uh oh!
There was an error while loading. Please reload this page.
Allow SQL TypePlanner to plan SQL types as extension types - #20676
Conversation
Uh oh!
There was an error while loading. Please reload this page.
e00cd32 to
e0c56f2Compare
alamb
left a comment
There was a problem hiding this comment.
Thanks @paleolimbot -- this looks good to me
The only question I have is if we can document the best practices for people implementing TypePlanner (it seems like maybe the best practice is always to implement both plan_type and plan_type_field?) Also perhaps we could consider deprecating plan_type 🤔
| /// | ||
| /// Returns None if not possible. The default implementation falls back | ||
| /// on plan_type and wraps it in a nullable field reference. | ||
| fn plan_type_field( |
There was a problem hiding this comment.
Maybe we can help document how this is different from plan_type (or should we be deprecating plan_type in favor of plan_type_field?
paleolimbot
commented
Mar 4, 2026
I added the deprecation here and a note on the reason for using the new member. Thanks! |
alamb
commented
Mar 9, 2026
Thanks @paleolimbot |
Uh oh!
There was an error while loading. Please reload this page.
…20676) ## Which issue does this PR close? - Closesapache#20675 ## Rationale for this change The existing enum `SQLDataType` has a number of existing members that have canonical Arrow extension type equivalents; however, the `TypePlanner` trait only supports returning `DataType` (which cannot represent an Arrow extension type). This will be substantially more useful after apache#18136, as the SQL planner inserts casts in a number of places (and currently the extension metadata of those casts is dropped when the logical cast is created). ## What changes are included in this PR? This PR adds a `fn plan_type_field()` member to the `TypePlanner` trait. The only place that the previously existing `plan_type()` member was called was already wrapping it in a `FieldRef` and so few other changes were needed. ## Are these changes tested? Yes ## Are there any user-facing changes? Existing `TypePlanner`s will continue to work and an example was added for supporting the UUID type.
Which issue does this PR close?
TypePlannerto plan SQL types as extension types #20675Rationale for this change
The existing enum
SQLDataTypehas a number of existing members that have canonical Arrow extension type equivalents; however, theTypePlannertrait only supports returningDataType(which cannot represent an Arrow extension type).This will be substantially more useful after #18136, as the SQL planner inserts casts in a number of places (and currently the extension metadata of those casts is dropped when the logical cast is created).
What changes are included in this PR?
This PR adds a
fn plan_type_field()member to theTypePlannertrait. The only place that the previously existingplan_type()member was called was already wrapping it in aFieldRefand so few other changes were needed.Are these changes tested?
Yes
Are there any user-facing changes?
Existing
TypePlanners will continue to work and an example was added for supporting the UUID type.