Skip to main content
๐Ÿ“˜ Complete PDF

Snowflake Certification Practice Test 03

Practice Test 03

Question 1 of 20
๐Ÿ“‹ Multiple Choice
Question 41
A retail data engineer receives daily product catalog updates formatted as JSON payloads containing unpredictable attributes, nested product specifications, and variable tags. Which Snowflake native data type is optimized specifically for storing and querying semi-structured data (JSON, Avro, ORC, Parquet, XML) up to 16 MB per value?
A. VARCHAR(MAX)
B. BLOB
โœ“
C. VARIANT
D. GEOGRAPHY
Answer
โœ… C. VARIANT
Explanation

1. Concept Overview Snowflake provides first-class support for semi-structured data using the **VARIANT** data type. A single VARIANT column can store complete hierarchical JSON documents, arrays, key-value objects, XML, Avro, ORC, or Parquet structures up to 16 MB in uncompressed size.

2. Why the Correct Option is Right The **VARIANT** data type is engineered specifically for semi-structured data. Snowflake parses the internal structure upon load, stores attributes columnarly under the hood, collects min/max statistics on sub-elements, and allows direct querying via standard SQL colon notation (`payload:product_name::string`).

3. Why Other Options Are Incorrect - **VARCHAR(MAX):** Stores raw unstructured text strings. Querying JSON inside a VARCHAR requires expensive runtime string parsing and regex, without columnar optimization or indexing. - **BLOB:** Stores unparsed binary data; Snowflake does not provide a native BLOB type for relational semi-structured querying. - **GEOGRAPHY:** Stores geospatial data (points, polygons, lines) following the WGS 84 coordinate reference system, not semi-structured JSON documents.

4. Production Scenario / Code Example

-- Creating a table with a VARIANT column for raw JSON payloads
CREATE OR REPLACE TABLE raw_product_catalog (
  product_id INT,
  ingested_at TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(),
  raw_payload VARIANT
);

-- Querying nested JSON attributes using colon notation and casting
SELECT 
  product_id,
  raw_payload:brand::STRING AS brand_name,
  raw_payload:specs.weight_kg::FLOAT AS weight,
  raw_payload:tags[0]::STRING AS primary_tag
FROM raw_product_catalog
WHERE raw_payload:in_stock::BOOLEAN = TRUE;

5. Real-World Architecture Context In traditional databases, ingesting semi-structured data required designing complex normalized schemas with dozens of tables before loading. In Snowflake's ELT paradigm, data engineers ingest raw JSON directly into a VARIANT column and extract or flatten attributes downstream using SQL.

6. Common Pitfalls & Anti-Patterns - **Omitting explicit type casting (`::string`, `::int`):** Querying `raw_payload:brand` without casting returns a VARIANT string containing literal double quotes (`"Nike"`). Always cast (`::STRING`) to strip JSON quotes. - **Storing structured data in VARIANT unnecessarily:** If a dataset has a rigid, unchanging relational schema (e.g., standard billing ledgers), storing it in fixed typed columns (INT, DECIMAL, DATE) is slightly more performant than VARIANT.

7. Performance & Cost Considerations Snowflake automatically detects common paths in VARIANT columns and stores them columnarly in micro-partitions. This enables micro-partition pruning on nested JSON paths without needing pre-built secondary indexes.

8. Exam / Interview Tip Remember the size limit: A single VARIANT value can store up to **16 MB** of uncompressed semi-structured data.

9. Key Takeaways - VARIANT stores JSON, XML, Avro, ORC, and Parquet natively. - Supports colon notation (`col:path::type`) for direct SQL extraction. - Automatic columnar optimization and pruning on nested attributes.

10. Related Tutorials & Resources - [Flatten Function & VARIANT Type](/tutorials/snowflake/snowflake-flatten-variant) - [Handling Semi-Structured Data in Snowflake](/tutorials/snowflake/snowflake-semi-structured-data)`

Answered: 0 / 20
Question Navigator (Test 03)0% Answered