datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Extend `DESCRIBE` statement to output the schema

Open comphead opened this issue 6 months ago • 0 comments

Is your feature request related to a problem or challenge?

I'm finding slightly confusing how to output the schema of particular query, the workaround I use is

> create table t1 as select map_extract(map([1], ['a']), 1)[1];
0 row(s) fetched. 
Elapsed 0.011 seconds.

> describe t1;
+---------------------------------------------------------------------------------+-----------+-------------+
| column_name                                                                     | data_type | is_nullable |
+---------------------------------------------------------------------------------+-----------+-------------+
| map_extract(map(make_array(Int64(1)),make_array(Utf8("a"))),Int64(1))[Int64(1)] | Utf8      | NO          |
+---------------------------------------------------------------------------------+-----------+-------------+
1 row(s) fetched. 
Elapsed 0.001 seconds.

it would be more clear to use something like in duck db

D describe select map_extract(map([1], ['a']), 1)[1];
┌────────────────────────────────────────────────────────────────────┬─────────────┬─────────┬─────────┬─────────┬─────────┐
│                            column_name                             │ column_type │  null   │   key   │ default │  extra  │
│                              varchar                               │   varchar   │ varchar │ varchar │ varchar │ varchar │
├────────────────────────────────────────────────────────────────────┼─────────────┼─────────┼─────────┼─────────┼─────────┤
│ map_extract("map"(main.list_value(1), main.list_value('a')), 1)[1] │ VARCHAR     │ YES     │         │         │         │
└────────────────────────────────────────────────────────────────────┴─────────────┴─────────┴─────────┴─────────┴─────────┘
D

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

comphead avatar Jun 17 '25 16:06 comphead