Skip to content

Create Struct table with explicit type and name #10207

@jayzhan211

Description

@jayzhan211

Is your feature request related to a problem or challenge?

Currently we can build struct table like this

statement ok
create table t as values (struct(1, 'a')), (struct(2, 'b'));

query ?
select * from t;
----
{c0: 1, c1: a}
{c0: 2, c1: b}

If we want to name them, we need to build with named_struct

statement ok
create table t as values (named_struct('number', 1, 'varchar', 'a')), (named_struct('number', 2, 'varchar', 'b'));

query ?
select * from t;
----
{number: 1, varchar: a}
{number: 2, varchar: b}

I hope we can build the struct table with pre-defined type and name

statement error DataFusion error: This feature is not implemented: Unsupported SQL type Custom\(ObjectName\(\[Ident \{ value: "struct", quote_style: None \}\]\), \["n", "int", "s", "varchar"\]\)
create table t (s struct(n int, s varchar)) as values (struct(1, 'a')), (struct(2, 'b'));

query ?
select * from t;
----
{n: 1, s: a}
{n: 2, s: b}

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

Similar to DuckDB
https://duckdb.org/docs/sql/data_types/struct#creating-structs-with-the-row-function

Metadata

Metadata

Assignees

No one assigned

    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