Skip to content

R2 SQL supports querying struct, array, and map column types stored in Iceberg tables. This page covers access patterns, supported functions, and examples for each type.


Structs

Struct columns contain named fields. Access fields using bracket notation or the get_field() function.

Bracket notation

SELECT pricing['price'] AS price,
pricing['discount_percent'] AS discount
FROM my_namespace.products
LIMIT 5

get_field function

SELECT get_field(pricing, 'price') AS price,
get_field(pricing, 'discount_percent') AS discount
FROM my_namespace.products
LIMIT 5

Struct fields in WHERE

SELECT customer_id, pricing['price'] AS price
FROM my_namespace.products
WHERE pricing['price'] > 50
LIMIT 10

Struct fields in ORDER BY

SELECT customer_id, pricing['price'] AS price
FROM my_namespace.products
WHERE pricing['price'] IS NOT NULL
ORDER BY pricing['price'] DESC