Skip to content

Conversation

@aspett
Copy link
Contributor

@aspett aspett commented Oct 20, 2025

Adds support for :struct & {:struct, columns} types in Adbc.Column.to_list

Fixes an issue where reading data through Table.to_rows() would return %Adbc.Column{} values.

struct_to_list(data)
end

def to_list(%Adbc.Column{data: data, type: {:struct, _columns}}) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the typespec above, it can only be type: :struct, never {:struct, _columns}. Is this clause necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have to update the typespec, but yes I only implemented this after coming across it 😅. You can reproduce it with a duckdb query like

CREATE TABLE t (col1 text, col2 text)
INSERT INTO t VALUES ('val1', 'val2');
SELECT struct_pack(col1 := col1, col2 := col2) FROM t
iex(6)> Adbc.Connection.query(conn, "SELECT struct_pack(col1 := col1, col2 := col2) FROM t")
{:ok,
 %Adbc.Result{
   num_rows: 0,
   data: [
     %Adbc.Column{
       name: "struct_pack(col1 := col1, col2 := col2)",
       type: {:struct,
        [
          %Adbc.Column{
            name: "col1",
            type: :string,
            nullable: true,
            metadata: nil,
            data: nil,
            length: nil,
            offset: nil
          },
          %Adbc.Column{
            name: "col2",
            type: :string,
            nullable: true,
            metadata: nil,
            data: nil,
            length: nil,
            offset: nil
          }
        ]},
       nullable: true,
       metadata: nil,
       data: [#Reference<0.2903375071.2569404447.12019>],
       length: nil,
       offset: nil
     }
   ]
 }}

@josevalim
Copy link
Contributor

It would be nice to standardize in one or the other. Perhaps the type: :struct is the one that is not actually used and the typespecs are out of date? But in general we should not have two representations for structs. :)

@josevalim josevalim merged commit ecf06ac into livebook-dev:main Oct 24, 2025
3 checks passed
@josevalim
Copy link
Contributor

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants