Nested Structs
A struct field can hold another struct, not just a scalar. This lets you model richer data without losing type safety.
Defining Embedded Types
Define the inner type first, then reference it by name in the outer type:
create type main.Address struct { street: String, city: String };
create type main.User struct { id: Int64, address: main.Address };
create table main.users : main.User { primary key (id) };
Inserting
Use an inline struct literal { ... } wherever a nested struct is expected:
insert into main.users { id: 1, address: { street: "Main St", city: "NYC" } };
insert into main.users { id: 2, address: { street: "Broadway", city: "LA" } };
Querying
select * flattens nested fields using dotted column names:
select * from main.users;
You will see columns id, address.street, and address.city.
Filtering on Nested Fields
Use the same dotted path in a where clause:
select * from main.users where address.city = "NYC";
You can also use a table alias, which makes the path explicit:
select * from main.users as u where u.address.city = "LA";
Deep Nesting
Structs can be nested to any depth. Each level adds another segment to the dotted path:
create type main.Country struct { code: String };
create type main.Address2 struct { street: String, country: main.Country };
create type main.Contact struct { id: Int64, address: main.Address2 };
create table main.contacts : main.Contact { primary key (id) };
insert into main.contacts { id: 1, address: { street: "Main St", country: { code: "US" } } };
select * from main.contacts;
The deepest field appears as address.country.code in the result.