Arrays of complex type always evaluate to ARRAY<STRING>?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 06:33 AM
Arrays of complex types seemingly always evaluate to ARRAY<STRING>. Therefore, casting or attempting to load JSON data with empty array values fails. For example, attempting to cast a JSON value of {"likes": []...} on load to the following table schema fail with the following error:
Schema:
array<struct<gid:string,user:struct<gid:string,name:string,resource_type:string>>>
Error:
"Error copy: [DATATYPE_MISMATCH.CAST_WITHOUT_SUGGESTION] Cannot resolve "likes" due to data type mismatch: cannot cast "ARRAY<STRING>" to "ARRAY<STRUCT<gid: STRING, user: STRUCT<gid: STRING, name: STRING, resource_type: STRING>>>"What is the best way to handle empty/null complex-typed arrays?