Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
plaflamme opened this issue Feb 6, 2024 · 1 comment · Fixed by #10537
Closed
1 task done

Comments

@plaflamme
Copy link

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
@Mytherin
Copy link
Collaborator

Mytherin commented Feb 8, 2024

Thanks for the report! I've implemented the casting in #10537 so this should work as expected now

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

Successfully merging a pull request may close this issue.

4 participants