Skip to content

Casting structs with fields of the same name, but in a different order fails with Mismatch Type Error #10486

@plaflamme

Description

@plaflamme

What happens?

Casting structs with fields of the same name, but in a different order fails with duckdb.duckdb.TypeMismatchException: Mismatch Type Error.

The documentation about casting structs only mention that field names have to match:

When casting structs, the names of fields have to match

If the requirement is that the fields have to be in the same order, then perhaps it could be made more explicit in the documentation.

To Reproduce

CREATE TABLE t1 (s STRUCT(a STRING, b INT));
INSERT INTO t1 SELECT {'b': 42, 'a': 'foo'};
duckdb.duckdb.TypeMismatchException: Mismatch Type Error: Type STRUCT(b INTEGER, a VARCHAR) does not match with STRUCT(a VARCHAR, b INTEGER). Cannot cast STRUCTs with different names

OS:

aarch64

DuckDB Version:

0.9.2

DuckDB Client:

python

Full Name:

Philippe Laflamme

Affiliation:

N/A

Have you tried this on the latest nightly build?

I have tested with a nightly build

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions