Semi-Structured & Structured Data
Read a clear definition, compare the concepts, then try the SQL or client command. Detailed explanations and diagrams remain available when you need them.
Before you begin
Intermediate · 9 lessons · About 108 minutes including detailed reading.
Prerequisite: Bulk Loading, Unloading & Schema Evolution. Reading needs no account. Manual SQL practice requires an authorized Snowflake account, suitable role and warehouse. Commands are examples, not executed by this website.
Complete Module 06 first. Early SELECT examples are self-contained. File exercises use the separate M7_LAB schema created in lesson 1, the supplied JSON/XML text and a small Parquet export. Load events.json before the final parent/child-table lab. Expected counts and totals are included for manual comparison.
Begin Module 07 →New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
What this module covers
- VARIANT, OBJECT, and ARRAY; PARSE_JSON and casting.
- JSON paths, dot/bracket notation, nested objects, and nested arrays.
- FLATTEN and LATERAL FLATTEN for nested-data transformations.
- Querying loaded JSON, Parquet, and XML data.
- Structured OBJECT, ARRAY, and MAP types; structured vs semi-structured modeling.
- Lab: Convert nested event data into relational tables.
Your lesson path
- Lesson 1 · About 12 min
VARIANT, OBJECT and ARRAY: read the shape first
An OBJECT holds named values, an ARRAY holds ordered values, and VARIANT can hold either shape or a scalar.
Read and practise → - Lesson 2 · About 12 min
JSON paths: reach a value and give it a type
Use a path to reach a nested value, then cast it to the SQL type needed by the query.
Read and practise → - Lesson 3 · About 12 min
Missing keys, JSON null and invalid input
A missing value, an explicit JSON null and invalid JSON are different situations. Keep enough evidence to tell them apart.
Read and practise → - Lesson 4 · About 12 min
FLATTEN: one array becomes several rows
FLATTEN is a table function. LATERAL lets it read each preceding source row and emit that row’s child values.
Read and practise → - Lesson 5 · About 12 min
Nested arrays: flatten one relationship at a time
For an array inside an array element, flatten the parent array first and feed its VALUE into the next FLATTEN.
Read and practise → - Lesson 6 · About 12 min
Load JSON and Parquet, then query the values
The file format determines how source bytes are read. After loading, query the stored fields using their actual names and types.
Read and practise → - Lesson 7 · About 12 min
XML: elements, attributes and content
Loaded XML uses Snowflake’s object representation. XMLGET selects a child element; GET reads its content or attributes.
Read and practise → - Lesson 8 · About 12 min
Typed OBJECT, ARRAY and MAP
Structured types declare the types inside a collection. They make nested contracts explicit.
Read and practise → - Lesson 9 · About 12 min
Lab: nested events to parent and child tables
Keep one table at event grain and another at item grain. Relate them by event_id and verify both.
Read and practise →