cblp opened a new pull request, #26893:
URL: https://github.com/apache/datafusion/pull/26893

   ## Which issue does this PR close?
   
   - Closes #26866.
   
   ## Rationale for this change
   
   `DESCRIBE`, `SHOW COLUMNS` and `information_schema.columns` show the storage 
type of a column, even if the column has a registered extension type. For 
example, a UUID column is shown as `FixedSizeBinary(16)`. Extension types can 
already customize how their values are formatted, but not how their type is 
named.
   
   With the canonical extension types registered, `DESCRIBE` of a table with a 
UUID column `u` and a plain column `i` now shows:
   
   ```
   u UUID  YES
   i Int32 NO
   ```
   
   Before, the first row was `u FixedSizeBinary(16) YES`.
   
   ## What changes are included in this PR?
   
   - New method `DFExtensionType::display_name(&self) -> Option<String>`. The 
default returns `None`, which means that the storage type is shown, as before. 
The name can depend on the metadata of the type, so parameterized names are 
possible.
   - New function 
`datafusion_expr::extension_types::field_type_display_name(registry, field)`. 
It returns the display name of the registered extension type of the field, or 
else the storage type. It also returns the storage type if the extension type 
is not registered or cannot be created from the field metadata, so that 
`DESCRIBE` does not fail on such a column.
   - `plan_describe` and `information_schema.columns` use this function. `SHOW 
COLUMNS` reads `information_schema.columns`, so it shows the same names.
   - `InformationSchemaProvider::with_extension_type_registry` passes the 
session registry to `information_schema`. `SessionState` sets it in all three 
places where it creates the provider.
   - `DFUuid` returns `UUID` and `DFJson` returns `JSON`. The other canonical 
extension types keep showing their storage type. I was not sure which names to 
use for them (for example for tensors, whose names would depend on the 
metadata) and am happy to add them here or in a follow-up.
   
   The canonical extension types are not registered in a default session, so 
the default output does not change.
   
   ## What is the testing strategy for this PR?
   
   - `extension_type_names.slt` registers the canonical extension types and a 
table with columns of registered types with and without a display name, of an 
unregistered extension type and of a plain type. It checks `DESCRIBE`, 
`information_schema.columns`, `SHOW COLUMNS` and a view.
   - A unit test for `field_type_display_name`, including the fallbacks.
   
   ## Are there any user-facing changes?
   
   Yes, sessions that register extension types with a display name, such as the 
canonical `arrow.uuid` and `arrow.json`, show that name in `DESCRIBE`, `SHOW 
COLUMNS` and `information_schema.columns`.
   
   There are no breaking API changes: the new trait method has a default 
implementation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to