https://delta.io logo
a

Afonso de Paula Feliciano

07/11/2023, 6:44 PM
Hello folks, could you help with a question about data types? I have this message when I try to read some parquet files where some of them have categories string column and others have categories with struct type, so, the problem is try to read simple and complex data types.
Failed to merge fields 'categories' and 'categories'. Failed to merge incompatible data types string and struct<_id:struct<$oid:string>,ancestors:array<string>,enabled:boolean,name:string>.
j

JosephK (exDatabricks)

07/11/2023, 7:41 PM
This is exactly why delta was invented, bc parquet doesn't work
a

Afonso de Paula Feliciano

07/11/2023, 7:41 PM
is there something to do? to handle with this situation?
j

JosephK (exDatabricks)

07/11/2023, 7:46 PM
First, make sure it doesn't happen again. You can read half the files with cat as a string, half with cat as a struct, cast them to whatever you want, do a union, then write it as delta