cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Arrays of complex type always evaluate to ARRAY<STRING>?

pt-jake
New Contributor II

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?

1 REPLY 1

Anonymous
Not applicable

Hi @Jake Neyer​ 

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance! 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group