Arrays & Nested Structures
How DataPancake handles object arrays, primitive arrays, and nested structures, including foreign key relationships and table generation.
Object Arrays
Definition: Arrays that contain objects (complex structures).
Characteristics:
Each array element is an object with its own attributes
Creates separate Dynamic Tables for array contents
Supports foreign key relationships to parent tables
Example:
ordersarray containing order objects
Code Generation:
Root table contains array reference
Separate table created for array contents (e.g.,
orders_array_object)Foreign key relationship links array table to root table
Polymorphic Version:
Named as
{attribute_name}_array_objectExample:
orders_array_object
Primitive Arrays
Definition: Arrays that contain primitive values (strings, numbers, booleans).
Characteristics:
Array elements are simple values, not objects
Stored as VARIANT or array types in Snowflake
May be flattened or kept as arrays depending on configuration
Example:
tagsarray containing string values
Array Primitive Type:
Specifies the data type of primitive array elements
Examples:
string,number,boolean
Polymorphic Version:
Named as
{attribute_name}_array_primitiveExample:
tags_array_primitive
Polymorphic Arrays
Definition: Arrays that contain both objects and primitives.
Characteristics:
Most complex array type
Requires careful handling in transformations
May need type checking in SQL expressions
Both
array_primitiveandarray_objectversions are activated
Handling:
DataPancake detects when an array contains both types
Both polymorphic versions are activated
Transformation expressions may need to handle both cases
Example:
In this case, both items_array_primitive and items_array_object would be active.
Nested Structures
Nested Objects
Attributes can be nested within objects at any depth:
Each level creates separate attributes:
customer(object)customer.contact(object)customer.contact.email(string)
Nested Arrays
Arrays can be nested within other arrays or objects:
Creates attributes:
orders(array)orders[0].items(array)orders[0].items[0].product_id(string)
Mixed Nesting
Complex structures combine objects and arrays:
Array Configuration
Foreign Key Relationships
For object arrays, you can configure foreign key relationships:
Links array table to parent table
Specifies which columns form the foreign key
Configures relationship type (many-to-one, one-to-one)
Sets join type (left outer, inner)
Array Metadata
Arrays have additional metadata fields:
Array Type -
'object','primitive', or'primitive,object'Array Primitive Type - For primitive arrays, the element data type
Array Relationship Name - Name of the relationship
Array Relationship Description - Description of the relationship
Last updated
Was this helpful?