Courseiva

CCNA Data Transformation Questions

40 questions · Data Transformation · All types, answers revealed

1
MCQeasy

A data engineer is converting a column of strings into integers. Some rows contain non-numeric characters that would normally cause the query to fail. Which function should be used to return a NULL value instead of an error when a conversion is impossible?

A.AS_INTEGER()
B.TO_DECIMAL()
C.TRY_CAST()
D.COALESCE()
AnswerC

TRY_CAST is the safest choice for transformations where data quality is uncertain. It attempts to convert the value to the specified data type, but if the conversion fails, it returns NULL instead of raising an exception. This ensures that a few bad records do not crash an entire batch processing job.

Why this answer

Data quality issues are common during transformation. Standard casting functions like CAST() or TO_NUMBER() are strict and will terminate a query if they encounter invalid input. To build resilient pipelines, engineers use 'try' variants of these functions, which gracefully handle errors by returning a NULL, allowing the rest of the dataset to be processed without interruption.

Exam trap

Candidates rely on standard CAST() or TO_NUMBER() functions, which abort the entire query execution upon encountering unexpected non-numeric character strings.

2
MCQmedium

A data engineer needs to perform a complex transformation that involves reading from a source table and writing to multiple target tables in a single transaction. What is the recommended strategy?

A.Use an asynchronous task for each target table to run in parallel.
B.Wrap the multiple INSERT statements in a single BEGIN...COMMIT transaction block.
C.Create a separate stored procedure for each insert to reduce complexity.
D.Use a series of independent views to union the data instead of writing to tables.
AnswerB

Wrapping multiple DML operations in a BEGIN/COMMIT block guarantees atomicity. If any statement fails, the entire transaction can be rolled back, ensuring that either all target tables are updated correctly or none are, maintaining the integrity of the data across the whole schema.

Why this answer

Using an explicit transaction block (BEGIN...COMMIT) ensures that multiple DML statements are treated as a single atomic unit. This is critical for data consistency, particularly when updating related tables simultaneously. If any part of the transformation fails, the transaction can be rolled back, ensuring the system remains in a valid, predictable state, which is a core requirement for reliable enterprise data pipelines.

Exam trap

Candidates often confuse individual SQL statement execution with atomic transactions. They forget that without an explicit BEGIN/COMMIT block, each statement executes independently, risking partial updates if a failure occurs.

3
MCQhard

A data engineer is designing a transformation that requires unpivoting a wide table with columns `q1_sales`, `q2_sales`, `q3_sales`, and `q4_sales` into a long format with columns `quarter` and `sales`. The table has millions of rows. Which Snowflake construct should be used to achieve this efficiently?

A.Use the `PIVOT` clause in a SELECT statement.
B.Use a `LATERAL FLATTEN` on an array constructed from the quarter columns.
C.Use the `UNPIVOT` clause in a SELECT statement.
D.Use a series of `UNION ALL` SELECT statements, one for each quarter column.
AnswerC

UNPIVOT is a built-in Snowflake clause that rotates columns into rows. It is optimized for this operation and can handle millions of rows efficiently. By specifying the columns to unpivot and the output column names, the engineer can transform the wide table into a long format in a single statement.

Why this answer

The UNPIVOT clause is specifically designed to transform columns into rows. It is a native Snowflake feature that is optimized for performance on large tables. Using UNION ALL or LATERAL FLATTEN can achieve similar results but with more complexity and potentially less efficiency.

PIVOT does the reverse and is not appropriate here.

Exam trap

The trap here is confusing PIVOT and UNPIVOT, or assuming that manual UNION ALL is the only way to unpivot.

4
MCQmedium

A data engineer is building a transformation pipeline that must parse semi-structured log data stored in a VARIANT column named log_data. The JSON structure contains a nested array under the key 'events', and each element in the array has a 'timestamp' field. The engineer needs to produce one row per event with the timestamp extracted as a TIMESTAMP_NTZ value. Which SQL construct should be used to achieve this transformation efficiently?

A.Use the FLATTEN function with the LATERAL keyword to explode the 'events' array, and access the 'timestamp' field using the colon notation, casting it to TIMESTAMP_NTZ.
B.Use the GET_PATH function to directly extract the 'timestamp' field from the array without exploding it, relying on implicit casting to TIMESTAMP_NTZ.
C.Use the OBJECT_CONSTRUCT function to rebuild the JSON, then use a JavaScript UDF to iterate over the array and return each timestamp.
D.Use the PARSE_JSON function to convert the VARIANT to a string, then use SPLIT_TO_TABLE to separate the array elements, and finally extract the timestamp with regular expressions.
AnswerA

FLATTEN with LATERAL is designed to explode nested arrays in VARIANT data, producing one row per element. The colon notation accesses nested fields, and casting ensures the correct data type. This approach is efficient and standard for transforming semi-structured data in Snowflake.

Why this answer

The FLATTEN function with LATERAL is the standard Snowflake construct for exploding nested arrays in VARIANT columns. It produces one row per array element, and the colon notation allows direct access to nested fields. Casting the extracted value to TIMESTAMP_NTZ ensures the correct data type for downstream processing.

This method is efficient and leverages Snowflake's native semi-structured data handling.

Exam trap

The trap here is assuming that GET_PATH or PARSE_JSON can directly explode arrays into rows, but they cannot; only FLATTEN with LATERAL performs that row multiplication.

5
MCQmedium

In a data transformation pipeline, what is the primary benefit of using 'Zero-Copy Cloning' for creating a development environment from production data?

A.It ensures that any changes made in the clone are immediately reflected in the production source.
B.It provides a metadata-only copy that does not incur additional storage costs until the data is modified.
C.It automatically transforms the data into a more efficient format for testing.
D.It encrypts the data using a different key to ensure developer privacy.
AnswerB

Zero-copy cloning simply points to the existing micro-partitions of the source table. Because no data is moved, the operation is nearly instantaneous and free. Only when the data in the clone is modified (e.g., through a transformation) are new micro-partitions created, incurring incremental storage costs.

Why this answer

Zero-copy cloning is a unique Snowflake feature that allows for the creation of identical copies of tables, schemas, or databases without duplicating the underlying data. This is a game-changer for data engineers, as it enables safe, isolated testing of transformations using real-world data volumes without the time or cost associated with traditional data movement.

Exam trap

Candidates often think zero-copy clones duplicate physical blocks right away, leading them to miscalculate storage implications when answering questions about development best practices.

6
MCQeasy

Which feature allows a Data Engineer to define a transformation pipeline where the target table automatically updates when the source table changes, without needing to manually define a schedule?

A.Tasks with Streams
B.Dynamic Tables
C.Materialized Views
D.Stored Procedures
AnswerB

Dynamic Tables are designed for declarative pipelines. You define the transformation query, and Snowflake automates the materialization and incremental updates. This eliminates the need for manual scheduling or monitoring of complex task chains, greatly simplifying the data engineering workflow for continuous transformation tasks.

Why this answer

Dynamic Tables provide a declarative approach to data engineering. By defining the target table based on a SQL query, Snowflake manages the dependency graph and incrementally updates the data. This abstracts away the complexity of managing tasks, streams, and manual refresh schedules, making it the most modern and efficient way to handle continuous data transformation in a pipeline.

Exam trap

Test-takers often confuse Dynamic Tables with traditional Tasks or Streams, failing to recognize that Dynamic Tables automatically manage schedules and dependencies declaratively.

7
MCQhard

Refer to the exhibit. A data engineer applies search optimization to a table to speed up point lookups. How does this transformation impact the storage and maintenance costs for the table?

A.It has no impact on storage as it uses the existing metadata of the micro-partitions.
B.It increases storage costs and uses serverless compute for maintenance.
C.It only increases compute costs during the initial build phase, with no ongoing costs.
D.It reduces storage costs by compressing the base table micro-partitions more efficiently.
AnswerB

When search optimization is enabled, Snowflake builds a search access path. Maintaining this path as the table is updated requires serverless compute resources, which are billed to the account. Additionally, the search access path itself occupies storage, adding to the monthly storage bill for that specific database object.

Why this answer

The Search Optimization Service is a background process that creates a persistent search access path (index-like structure). It significantly improves performance for point lookups but comes at a cost. The service consumes both storage for the search access path and serverless compute for the background maintenance as data in the base table is modified over time.

Exam trap

Many candidates incorrectly believe that the search optimization service only incurs standard table storage costs without utilizing background serverless compute resources for ongoing maintenance.

8
Multi-Selectmedium

A data engineer is using Snowpark for Python to perform transformations on a Snowflake table. The engineer wants to leverage Snowpark's capabilities for data transformation. Which two statements accurately describe Snowpark's features for transformation? (Choose two.)

Select 2 answers
A.Snowpark automatically caches all intermediate transformation results in memory on the client side to speed up iterative development.
B.Snowpark requires data to be extracted to a local Python environment for any transformation that uses third-party libraries.
C.Snowpark allows you to write transformations using a DataFrame API that is lazily evaluated and executed on the Snowflake compute engine.
D.Snowpark provides a built-in visual interface for designing transformation pipelines without writing code.
E.Snowpark supports user-defined functions (UDFs) written in Python, Java, and Scala, which can be used within transformations.
AnswersC, E

Snowpark's DataFrame API is designed for lazy evaluation, meaning transformations are not executed until an action is triggered. The operations are pushed down to Snowflake's engine for execution, leveraging its scalability. This is a core feature that enables efficient processing of large datasets without pulling data to the client.

Why this answer

Snowpark's DataFrame API enables lazy evaluation and pushdown to Snowflake, and it supports UDFs in multiple languages. These two features are fundamental for performing transformations efficiently. The other options incorrectly describe Snowpark as caching client-side, requiring data extraction, or providing a visual interface, which are not accurate.

Exam trap

The trap here is assuming Snowpark caches data locally or requires data extraction for third-party libraries, when in fact it pushes computation to Snowflake and supports dependencies within UDFs.

9
MCQhard

A data engineer needs to transform a large fact table by adding a column that contains the previous row's `sale_amount` partitioned by `customer_id` and ordered by `sale_date`. The table has billions of rows, and the transformation must run efficiently without shuffling data unnecessarily. Which Snowflake feature should be used to achieve this?

A.Use a correlated subquery that selects the maximum `sale_amount` from the same table where `sale_date` is less than the current row's `sale_date`.
B.Use the `LAG` window function with a `PARTITION BY customer_id ORDER BY sale_date` clause.
C.Use the `LEAD` window function with a `PARTITION BY customer_id ORDER BY sale_date` clause and then reverse the order.
D.Use a self-join on `customer_id` where the right table's `sale_date` is less than the left table's `sale_date`, then filter to the maximum right `sale_date`.
AnswerB

LAG is designed to access a previous row within a window. Partitioning by customer_id and ordering by sale_date ensures the previous sale for each customer is correctly identified, and Snowflake's optimizer can leverage clustering or partitioning to reduce data movement, making it efficient for large tables.

Why this answer

The LAG window function is specifically designed to return a value from a preceding row within a partition. Partitioning by customer_id and ordering by sale_date ensures the immediate previous sale for each customer is correctly identified. Snowflake's optimizer can handle large datasets efficiently with window functions, avoiding the costly shuffles typical of self-joins or correlated subqueries.

Exam trap

The trap here is thinking that a self-join or correlated subquery is necessary to access a previous row, when a window function like LAG is the optimized, correct tool.

10
MCQmedium

To comply with privacy regulations, a data engineer must ensure that certain columns in a table are masked for unauthorized users during transformation. Which Snowflake feature provides a way to define re-usable masking logic that is automatically applied at query time?

A.Row Access Policies
B.External Tables with encrypted files
C.Dynamic Data Masking Policies
D.Secure Views with hardcoded filters
AnswerC

Dynamic Data Masking allows for the creation of policies that use SQL logic (like CASE statements) to determine how data should appear. When assigned to a column, the policy transforms the output for unauthorized roles (e.g., replacing a social security number with 'XXX-XX-XXXX') while keeping the raw data intact.

Why this answer

Dynamic Data Masking is a security-focused transformation feature that allows engineers to protect sensitive data without changing the underlying stored values. By creating Masking Policies and applying them to columns, Snowflake ensures that the transformation (masking) happens dynamically based on the role and context of the user executing the query.

Exam trap

Candidates often confuse static table views or hardcoded column transformations with dynamic masking, missing that masking policies apply automatically based on user roles at query time.

11
MCQmedium

Which Snowflake feature helps in managing data transformation pipelines by providing a visual and programmatic way to handle task dependencies and state management?

A.Streams
B.Stored Procedures
C.Tasks with dependencies (DAG)
D.External Tables
AnswerC

Defining tasks with an 'AFTER' clause creates a DAG, allowing Snowflake to manage the execution order and dependencies automatically. This is the recommended approach for orchestrating complex transformation pipelines within the database, providing native support for success/failure triggers and clear visibility into the entire workflow.

Why this answer

A Directed Acyclic Graph (DAG) of tasks allows for complex, multi-step transformation sequences where each task can have dependencies on the success of prior tasks. This structure provides a clear, manageable workflow for production ELT. By centralizing the orchestration logic within Snowflake, engineers avoid the need for external workflow schedulers, simplifying the architecture and improving observability through standard Snowflake monitoring views and query history tools.

Exam trap

Test-takers often confuse DAG tasks with simple streams or dynamic tables, missing the specific orchestration structure provided by parent-child task dependencies.

12
Multi-Selectmedium

A data engineer is using Snowpark for Python to transform data. The engineer needs to perform a join between two DataFrames and then apply a filter based on a column from the joined result. Which TWO methods are appropriate for this transformation? (Choose two.)

Select 2 answers
A.Use `DataFrame.union()` to combine the DataFrames, then `DataFrame.filter()` to apply the condition.
B.Use `DataFrame.join()` to combine the DataFrames, then `DataFrame.where()` to apply the condition.
C.Use `DataFrame.join()` to combine the DataFrames, then `DataFrame.filter()` to apply the condition.
D.Use `DataFrame.join()` to combine the DataFrames, then `DataFrame.select()` to apply the condition.
E.Use `DataFrame.merge()` to combine the DataFrames, then `DataFrame.filter()` to apply the condition.
AnswersB, C

DataFrame.where() is an alias for filter() in Snowpark. After joining with DataFrame.join(), calling where() applies the filter condition to the joined DataFrame. This is functionally equivalent to using filter() and is a valid method for applying conditions in a Snowpark transformation pipeline.

Why this answer

In Snowpark, join() combines two DataFrames, and filter() or its alias where() applies a row-wise condition. These methods build a lazy query plan that executes on Snowflake. Other methods like merge(), union(), or select() do not perform a join followed by a row filter, so they are not appropriate for this transformation.

Exam trap

The trap here is confusing Snowpark DataFrame methods with SQL statements or other DataFrame libraries, such as assuming merge() performs a join.

13
MCQeasy

Which Snowflake feature is best suited for transforming data that is already loaded and requires periodic, complex SQL transformations without managing manual scheduling or streams?

A.Materialized Views
B.Dynamic Tables
C.Stored Procedures
D.External Tables
AnswerB

Dynamic tables allow for complex transformations involving joins, aggregations, and window functions. They automatically handle the incremental refresh logic, removing the need for manual task orchestration and stream tracking, making them the ideal choice for declarative data transformation pipelines within the Snowflake ecosystem.

Why this answer

Dynamic Tables provide a declarative approach to data transformation. Users define the query that represents the transformation, and Snowflake manages the refresh frequency, dependencies, and incremental updates automatically. This reduces the administrative burden compared to managing manual Tasks and Streams.

It is the modern standard for building ELT pipelines where the user describes the desired state, and the system ensures the target reflects the source over time.

Exam trap

Candidates often default to Tasks and Streams for simple pipelines. They miss that Dynamic Tables are specifically designed to abstract away the scheduling and incremental logic entirely.

14
MCQmedium

An engineer needs to ensure that a transformation pipeline handles 'late-arriving' data in a streaming context. Which feature is most effective?

A.Using a manual stored procedure to scan for missing data based on timestamps.
B.Using Dynamic Tables with a configured lag target.
C.Implementing a complex Python task to buffer all data in a queue before processing.
D.Overwriting the entire target table with every execution to ensure data integrity.
AnswerB

Dynamic Tables are specifically designed to handle incremental changes, including updates to existing records and late-arriving data. The system automatically manages the refreshes based on the lag target, ensuring that the target table remains consistent with the source data without manual intervention.

Why this answer

Snowflake's Dynamic Tables allow for declarative data transformation pipelines that automatically handle data state, including updates and late arrivals. By defining the lag, the engine manages the re-processing required to integrate new data into the final result set. This eliminates the need for manual handling of late data, which is historically a significant pain point in traditional ETL pipeline design.

Exam trap

Candidates often incorrectly suggest using Streams and Tasks for late-arriving data. While viable, Dynamic Tables are specifically designed to handle the state and refresh logic declaratively without manual orchestrations.

15
MCQmedium

Which transformation technique should be used when you need to pivot data from a long-form format (rows) to a wide-form format (columns) for reporting?

A.Using a series of CASE statements within a GROUP BY clause.
B.Using the PIVOT clause.
C.Using a self-join to correlate rows.
D.Using a stored procedure to iterate through rows.
AnswerB

The `PIVOT` clause is the native Snowflake operator for rotating data rows into columns. It is highly optimized and significantly more readable and maintainable than manual aggregation methods. It allows for flexible reporting by easily transforming datasets to meet the specific requirements of various business intelligence tools.

Why this answer

The `PIVOT` clause is designed specifically to rotate data from a row-based structure into a column-based format. By specifying the column to aggregate and the values to pivot, Snowflake transforms the data set, making it easier for BI tools to consume metrics directly. This is a common requirement when generating reports that represent time-series data or categorical breakdowns where metrics are required side-by-side rather than in long, narrow tables.

Exam trap

Candidates sometimes confuse PIVOT with UNPIVOT or manual conditional aggregation (CASE WHEN), forgetting that the PIVOT clause is the dedicated native syntax for this specific transformation.

16
MCQmedium

A data engineer is building a transformation pipeline that processes semi-structured event logs stored in a VARIANT column named `event_data`. The logs contain a nested array under the key `items`. The engineer needs to produce one output row per element in the array, preserving all other columns from the source table. Which Snowflake construct should be used to achieve this transformation?

A.LATERAL FLATTEN(input => event_data:items)
B.ARRAY_AGG(event_data:items)
C.OBJECT_CONSTRUCT('items', event_data:items)
D.PARSE_JSON(event_data:items)
AnswerA

LATERAL FLATTEN is designed to expand a VARIANT array into multiple rows, one per element. Because it is a lateral join, it can reference the VARIANT column from the source table and preserve all other columns, making it ideal for this scenario.

Why this answer

To expand a nested array into multiple rows while keeping the original columns, a lateral join with FLATTEN is required. LATERAL FLATTEN allows the FLATTEN function to access the VARIANT column from the preceding table and returns one row per array element, which is exactly the needed behavior. The other functions either aggregate, construct objects, or parse strings, none of which achieve row expansion.

Exam trap

The trap here is assuming that any function that references the array will automatically expand it, when only FLATTEN (used laterally) produces multiple rows.

17
MCQhard

When performing a MERGE operation to update a large table, which factor most significantly impacts the performance of the transformation?

A.The number of columns included in the SELECT list of the source query.
B.The clustering of the target table on the join column used in the MERGE statement.
C.The size of the virtual warehouse, as larger warehouses always make MERGE operations faster.
D.The use of an explicit transaction block around the MERGE statement.
AnswerB

Clustering on the join column allows the query optimizer to prune partitions that do not contain matching keys. This significantly reduces the amount of data read from storage, which is the most expensive part of a MERGE operation on large datasets.

Why this answer

The performance of a MERGE operation is primarily constrained by the join condition, specifically if the join column is not clustered or indexed. Because Snowflake does not use traditional indexes, clustering by the join key allows for effective partition pruning. Ensuring that the join criteria align with the table's clustering key is the most effective way to minimize data scanning and optimize the merge process.

Exam trap

Candidates often believe overall table size or source file count dictates MERGE performance, ignoring the critical impact of target table clustering on join keys.

18
MCQeasy

What is the primary benefit of using `CLONE` for data transformation and testing?

A.It automatically updates the source table with new transformations.
B.It provides a cost-effective way to create isolated development environments.
C.It allows for the conversion of Parquet files to internal tables.
D.It enables multi-region replication of data.
AnswerB

Because cloning creates a metadata-only copy, it is nearly instantaneous and consumes no additional storage until data is modified. This makes it the most efficient way to test complex data transformations against production-like data without the cost and time associated with traditional physical data duplication.

Why this answer

Cloning (Zero-Copy Cloning) allows an engineer to create a full copy of a table or database instantly without duplicating the underlying data. This is invaluable for testing transformations in a sandbox environment without incurring storage costs or taking up time for massive data movement. Any changes made in the cloned object are isolated from the original, ensuring that production pipelines remain unaffected during the development and validation of new transformation logic.

Exam trap

Candidates often assume that cloning a large table duplicates the underlying data storage immediately, leading them to worry about high storage costs and slow creation times when answering questions about sandbox environments.

19
MCQmedium

A Data Engineer needs to ensure that data in a target table is updated with changes from a source table while handling potential duplicate records. Which command should be used?

A.INSERT INTO ... SELECT DISTINCT
B.MERGE INTO target USING source ON ... WHEN MATCHED THEN UPDATE...
C.UPDATE target SET ... FROM source
D.CREATE OR REPLACE TABLE target AS SELECT ...
AnswerB

The MERGE command allows for conditional logic based on match status, which is ideal for deduplication and incremental updates. By defining specific matching criteria, it ensures that target table data remains accurate without creating duplicate rows, which is a common requirement in ETL/ELT pipelines.

Why this answer

The MERGE command is specifically designed for complex DML operations that combine insert, update, and delete actions in a single pass. By joining the source and target on a primary key, it ensures that new records are inserted while existing records are updated, preventing duplicates and ensuring data consistency. This is the standard method for slowly changing dimensions and incremental data synchronization in modern data warehousing pipelines.

Exam trap

Candidates often suggest using INSERT or UPDATE separately, failing to realize that MERGE is the only atomic way to handle both inserts and updates while avoiding duplicate records.

20
MCQeasy

A data engineer is transforming a table with a column `tags` stored as a VARIANT array of strings. The goal is to produce one row per tag for downstream aggregation. Which function should be used to expand the array into rows?

A.OBJECT_KEYS(tags)
B.ARRAY_TO_STRING(tags, ',')
C.FLATTEN(input => tags)
D.PARSE_JSON(tags)
AnswerC

FLATTEN is a table function that expands a VARIANT array into one row per element, exposing the value in a VALUE column. It is the standard Snowflake construct for unnesting arrays and is exactly what is needed to transform the `tags` array into rows for downstream aggregation.

Why this answer

FLATTEN is the Snowflake table function that unnests semi-structured arrays and objects into relational rows. When applied to a VARIANT array, it returns one row per element, making it the correct choice for expanding `tags` into individual rows. The other functions either concatenate, parse, or extract object keys, none of which achieve the required row-level expansion.

Exam trap

The trap here is confusing array-to-string conversion or JSON parsing with actual unnesting, which requires the FLATTEN table function.

21
MCQmedium

A data engineer is implementing a Python User-Defined Function (UDF) to perform complex string manipulation. To optimize performance for a large-scale transformation, the engineer wants to ensure the UDF processes multiple rows in a single call. Which type of UDF should be implemented?

A.A scalar Python UDF with a loop
B.A Vectorized Python UDF
C.A Python User-Defined Table Function (UDTF)
D.A JavaScript UDF using the 'async' keyword
AnswerB

Vectorized UDFs define a handler that receives a batch of input rows as a Pandas object. This allows the Python code to utilize highly optimized vectorized operations, which can be orders of magnitude faster than scalar processing. It minimizes the context switching between the SQL engine and the Python interpreter during the transformation.

Why this answer

Snowflake's Vectorized Python UDFs allow for high-performance processing by passing batches of rows as Pandas DataFrames or Series. This reduces the overhead associated with calling the function for every individual row. For data transformations involving heavy computational logic or libraries like NumPy, vectorized UDFs are significantly more efficient than standard scalar UDFs which process data row-by-row.

Exam trap

Candidates often confuse Vectorized UDFs with Standard UDFs, failing to realize that row-by-row processing is the default and significantly slower for large datasets.

22
MCQhard

A data engineer needs to join a large fact table to a small dimension table that changes slowly. The dimension has a `valid_from` and `valid_to` timestamp, and the fact rows have an `event_ts`. The engineer wants to avoid scanning the entire dimension for every fact row and must ensure the join uses the correct validity window. Which approach is most appropriate?

A.Use a LEFT OUTER JOIN on the dimension key and filter with `valid_to IS NULL` to get the current record.
B.Use an ASOF JOIN with `MATCH_CONDITION (event_ts >= valid_from)` and equality on the dimension key.
C.Use a non-equi join with `event_ts BETWEEN valid_from AND valid_to` and rely on the optimizer to prune partitions.
D.Use a CROSS JOIN with a WHERE clause that filters on the dimension key and timestamp range.
AnswerB

ASOF JOIN is designed for time-series lookups where the fact timestamp must fall on or after a dimension timestamp. By matching on the dimension key and using MATCH_CONDITION, it efficiently finds the most recent valid dimension row without scanning all validity windows, which is exactly the SCD lookup pattern needed here.

Why this answer

ASOF JOIN is purpose-built for joining time-series data to slowly changing dimensions by matching the closest preceding record. It uses MATCH_CONDITION to compare timestamps and equality predicates for the key, avoiding full scans and Cartesian products. The other options either ignore historical validity or rely on inefficient join types that do not scale for large fact tables.

Exam trap

The trap here is believing that a non-equi join or a simple NULL filter can efficiently handle SCD validity windows, when ASOF JOIN is the optimized construct for this pattern.

23
MCQhard

You are debugging a transformation pipeline where a task is failing with an 'Insufficient Privileges' error during a MERGE operation. The task is owned by a service account role. What is the most likely cause?

A.The task owner does not have the EXECUTE TASK privilege on the current schema.
B.The task owner lacks the required DML privileges on the target table being merged into.
C.The warehouse used by the task is currently suspended by another process.
D.The task is missing a dependency definition for the source table.
AnswerB

A task executes with the permissions of its owner. If the owner role does not have the necessary INSERT, UPDATE, or DELETE permissions on the target table, the MERGE operation will fail during execution. This is a standard security constraint enforced by Snowflake.

Why this answer

Tasks execute with the privileges of their owner. If the owner role lacks USAGE on the database, schema, or warehouse, or lacks the required DML permissions (INSERT/UPDATE/DELETE) on the target table, the task will fail. This is a common security best practice in Snowflake to ensure the principle of least privilege, requiring careful validation of all object-level permissions during the deployment phase.

Exam trap

Candidates often mistakenly check warehouse usage privileges when a task fails during a DML execution, overlooking object-level DML grants required on the target table.

24
Multi-Selectmedium

A data engineer is designing a transformation pipeline that uses Snowpark to process data. The pipeline must perform complex data cleaning and feature engineering. Which TWO capabilities of Snowpark are specifically designed to support these transformations? (Choose two.)

Select 2 answers
A.The ability to execute user-defined functions (UDFs) written in Python, Java, or Scala within Snowflake.
B.The ability to automatically materialize transformation results into a new table without explicit DDL.
C.The ability to execute transformations on data without moving it out of Snowflake's storage layer.
D.The ability to write transformations in Python, Java, or Scala using a DataFrame API similar to Apache Spark.
E.The ability to use the Snowpark ML library for building and deploying machine learning models directly in Snowflake.
AnswersA, D

Snowpark supports UDFs that can be written in Python, Java, or Scala and executed within Snowflake. This allows custom transformation logic to be applied to data at scale, which is essential for complex feature engineering and data cleaning tasks that go beyond built-in SQL functions.

Why this answer

Snowpark's DataFrame API allows developers to write transformations in Python, Java, or Scala, providing a familiar and expressive way to perform complex data cleaning and feature engineering. Additionally, Snowpark supports UDFs in these languages, enabling custom logic to be executed within Snowflake. These two capabilities directly empower the development of sophisticated transformation pipelines.

Exam trap

The trap here is confusing general benefits like processing data in-place or ML libraries with the specific transformation capabilities of Snowpark, namely the DataFrame API and UDFs.

25
MCQmedium

When migrating a large transformation from a legacy system to Snowflake, why is it recommended to prioritize ELT over ETL?

A.ELT is required to use Snowflake's external stage integration.
B.ELT minimizes data movement and leverages Snowflake's compute scalability.
C.Snowflake does not support traditional ETL transformation tools.
D.ETL is only possible using Snowflake's proprietary Java API.
AnswerB

ELT allows you to load raw data quickly and perform transformations using Snowflake’s engine, which is highly optimized for parallel execution. This avoids costly data movement and allows you to scale compute resources on-demand to handle even the most intensive transformation workloads.

Why this answer

Snowflake's architecture is optimized for ELT (Extract, Load, Transform), where data is loaded in raw form and transformed using Snowflake's massive compute power. This leverages the cloud data warehouse's scalability, parallel processing, and columnar storage. By moving the transformation logic into the warehouse, you avoid the bottlenecks and data movement costs associated with traditional ETL, resulting in significantly faster and more scalable data pipelines.

Exam trap

Candidates frequently choose ETL because it is a familiar legacy concept, ignoring that Snowflake's architecture is fundamentally built to leverage ELT for massive parallel processing and performance.

26
MCQhard

A data engineer is transforming a large fact table using a complex SQL query that includes multiple window functions and joins. The query is executed frequently and must return results with minimal latency. The engineer notices that the query spends significant time on repartitioning data for window functions. Which Snowflake feature should be used to improve performance by pre-organizing the data to avoid repartitioning?

A.Use the RESULT_SCAN function to cache the query results and reuse them.
B.Apply search optimization on the columns used in the window functions.
C.Create a materialized view that pre-computes the window functions.
D.Define a clustering key on the columns used in the PARTITION BY clause of the window functions.
AnswerD

Clustering keys physically sort data by the specified columns, which aligns with the PARTITION BY clause of window functions. This reduces the need for repartitioning during query execution, as data is already co-located. For large tables with frequent window function queries, clustering can significantly improve performance by minimizing data movement.

Why this answer

Clustering keys physically order data by the specified columns, which can align with the PARTITION BY clause of window functions. This reduces the need for Snowflake to repartition data at query runtime, leading to faster execution. For large fact tables with frequent window function queries, clustering is the recommended approach to optimize performance by minimizing data movement.

Exam trap

The trap here is confusing search optimization with clustering; search optimization speeds up point lookups, not window function partitioning.

27
MCQmedium

Which function is best suited for converting a string representation of a JSON object into a VARIANT type within a transformation query?

A.TO_VARIANT()
B.TRY_CAST(data AS VARIANT)
C.PARSE_JSON()
D.TO_JSON()
AnswerC

PARSE_JSON is the specific function built to transform a string containing JSON into a hierarchical VARIANT object. This enables the use of Snowflake's native path-based querying, which is essential for transforming complex, nested data into relational structures during the pipeline process.

Why this answer

The PARSE_JSON function is the standard Snowflake tool for casting string data into the VARIANT format. Once in the VARIANT format, the data can be queried using path notation (e.g., col:field), enabling powerful transformations on nested or semi-structured data. This is a foundational operation in data ingestion pipelines where raw data often arrives as strings in CSV or Parquet files.

Exam trap

Candidates often confuse TO_VARIANT with PARSE_JSON. While both relate to semi-structured data, PARSE_JSON is the specific function required to convert a raw string into a queryable JSON object.

28
MCQmedium

A data engineer is transforming semi-structured event logs stored in a VARIANT column named event_data. The column contains an array of objects under the key 'items', where each object has a 'product_id' and a 'quantity'. The engineer needs to produce one row per product per event, with the event's timestamp and user ID repeated. Which SQL construct should be used to achieve this transformation?

A.Employ a recursive common table expression (CTE) to iterate over the array elements and output one row per element.
B.Use the PARSE_JSON function to convert event_data:items into a relational table with columns for product_id and quantity.
C.Use the LATERAL FLATTEN function on event_data:items to expand the array into separate rows.
D.Apply the ARRAY_AGG function to event_data:items to concatenate the array elements into a single string.
AnswerC

LATERAL FLATTEN is designed to explode semi-structured arrays into multiple rows, preserving the parent row's context. Applied to event_data:items, it yields one row per element, making product_id and quantity accessible via VALUE:product_id and VALUE:quantity. This directly satisfies the requirement to produce one row per product per event while repeating the event timestamp and user ID.

Why this answer

LATERAL FLATTEN is the idiomatic Snowflake construct for expanding semi-structured arrays into rows. When applied to event_data:items, it produces one row per array element, allowing direct access to nested attributes like product_id and quantity. Other options either aggregate, parse, or manually iterate, none of which efficiently achieve the required row-level expansion while preserving parent context.

Exam trap

The trap here is assuming that aggregation functions like ARRAY_AGG can unnest arrays, when in fact they perform the opposite operation.

29
MCQhard

A data engineer is transforming a large table with a VARIANT column that contains nested arrays. The goal is to produce one row per element in the array, preserving all other columns. The engineer uses the FLATTEN function with the LATERAL keyword. Which behavior should the engineer expect when the VARIANT column contains an empty array?

A.The row is retained with NULL values for the flattened columns.
B.The row is omitted from the result set because FLATTEN produces no rows for an empty array.
C.The query fails with an error because FLATTEN cannot process empty arrays.
D.The row is retained with an empty array in the flattened column.
AnswerB

When FLATTEN is applied to an empty array, it generates zero output rows. With a LATERAL join, the outer row is eliminated because there are no matching rows from the flattened side. This is standard SQL behavior for lateral joins with empty sets. The engineer must be aware that empty arrays cause data loss unless handled with an outer join or a default value.

Why this answer

FLATTEN with LATERAL produces one row per element in the array. When the array is empty, there are no elements, so no rows are generated, and the outer row is excluded from the result. This is consistent with inner join semantics.

To retain such rows, an outer join with LATERAL FLATTEN is needed. The correct expectation is that the row is omitted.

Exam trap

The trap here is assuming that an empty array will yield a row with NULLs, when in fact it yields no rows and can silently drop data in an inner lateral join.

30
MCQeasy

A data engineer is working with a table that contains a column of type VARCHAR storing JSON strings. The engineer needs to transform this column into a VARIANT type to leverage Snowflake's semi-structured data functions. Which function should be used to convert the VARCHAR column to VARIANT?

A.CAST
B.TO_VARIANT
C.TRY_PARSE_JSON
D.PARSE_JSON
AnswerD

PARSE_JSON interprets a string as a JSON document and returns a VARIANT. It is specifically designed to convert JSON-formatted strings into Snowflake's semi-structured VARIANT type, allowing access to nested fields using colon notation. This is the correct function for this transformation.

Why this answer

PARSE_JSON is the dedicated function for converting a JSON-formatted string into a VARIANT. It parses the string and creates a structured object that can be queried using Snowflake's semi-structured data functions. This transformation is essential for enabling access to nested JSON elements and is the recommended approach for converting VARCHAR JSON to VARIANT.

Exam trap

The trap here is assuming that TO_VARIANT or CAST can parse JSON; they only convert the string as a scalar, not as structured JSON.

31
MCQmedium

A data engineer is building a transformation pipeline that must read semi-structured events from a stage, parse them, and write the output to a target table. The pipeline will run on a schedule and must be version-controlled and testable like other software artifacts. The team wants to avoid writing SQL scripts that are hard to unit test. Which Snowflake feature should the engineer use to implement this transformation?

A.A materialized view over the stage
B.A series of SQL scripts executed by a task
C.Snowpipe with a transformation function
D.Snowpark with a Python stored procedure
AnswerD

Snowpark lets the engineer write transformations in Python, which can be unit tested with standard frameworks before deployment. The code can be stored in a Git repository and executed as a stored procedure or in a Snowpark session. This aligns with the requirement for version control and testability, unlike pure SQL scripts. It also handles semi-structured data natively through DataFrame APIs.

Why this answer

Snowpark is the appropriate choice because it allows developers to write transformation logic in Python, which can be unit tested and version controlled. It also integrates with Snowflake's compute and handles semi-structured data. The other options either lack testability, are not designed for complex transformations, or are technically invalid for the described use case.

Exam trap

The trap here is assuming that any scheduled SQL execution provides the same software engineering benefits as a programming language, when in fact testability and version control are not inherent to SQL scripts.

32
MCQmedium

A data engineer needs to filter the results of a complex analytical query based on the result of a window function. The query calculates a rolling average of sales per region and should only return rows where the current sale exceeds that average. Which SQL clause is most efficient for this transformation?

A.The WHERE clause
B.The HAVING clause
C.The QUALIFY clause
D.The GROUP BY clause
AnswerC

The QUALIFY clause is specifically designed to filter the results of window functions after they have been computed. It functions similarly to how HAVING works for aggregates, providing a clean syntax to remove rows that do not meet criteria. This reduces code complexity by eliminating the need for wrapping the primary query in a subquery.

Why this answer

Filtering on window functions requires a mechanism that executes after the window calculations are performed. The QUALIFY clause allows engineers to filter results directly in the SELECT statement without nesting logic inside a subquery or a Common Table Expression. This significantly improves query readability and can lead to internal optimizations by the Snowflake query optimizer during the execution phase.

Exam trap

Candidates often write complex nested subqueries or CTEs to filter window functions, unaware that the QUALIFY clause natively handles this efficiently in the same query block.

33
MCQmedium

A data engineer is working with a table that stores customer orders in a VARIANT column named order_details. The order_details column contains an array of line items under the key 'items'. Each line item is an object with keys 'product_id', 'quantity', and 'price'. The engineer needs to produce a flattened result set where each row represents a single line item with its associated order ID. Which Snowflake function should be used to achieve this transformation?

A.OBJECT_KEYS(order_details:items)
B.PARSE_JSON(order_details:items)
C.ARRAY_TO_STRING(order_details:items, ',')
D.LATERAL FLATTEN(input => order_details:items)
AnswerD

LATERAL FLATTEN is designed to explode arrays into multiple rows. Using it with the input parameter pointing to the items array will produce one row per element in the array. This allows each line item to be represented as a separate row, and the parent order ID can be included via the correlation. This is the standard and most efficient way to flatten arrays in Snowflake.

Why this answer

To transform an array of line items into individual rows, the LATERAL FLATTEN function is the correct choice. It takes a VARIANT array and outputs one row per element, allowing each line item to be processed separately. The other functions either aggregate, extract keys, or parse JSON but do not explode arrays into rows.

Exam trap

The trap here is confusing functions that manipulate arrays with those that explode them, such as using ARRAY_TO_STRING or OBJECT_KEYS instead of FLATTEN.

34
MCQeasy

A data engineer is working with a table that has a column `order_date` of type DATE. The engineer needs to create a new column that contains the year and month in the format 'YYYY-MM' (e.g., '2023-01') for each order. Which Snowflake function should be used to produce this formatted string?

A.DATE_TRUNC('month', order_date)
B.CONCAT(YEAR(order_date), '-', MONTH(order_date))
C.EXTRACT(YEAR_MONTH FROM order_date)
D.TO_CHAR(order_date, 'YYYY-MM')
AnswerD

TO_CHAR converts a date or timestamp to a string using the specified format. Using 'YYYY-MM' returns the year and month in the desired format. This is the standard function for formatting dates in Snowflake and is the simplest way to achieve the required transformation.

Why this answer

TO_CHAR with a format string is the correct function to convert a date into a custom string format. It directly produces the 'YYYY-MM' representation, including leading zeros for months. Other options either return a date, invalid syntax, or lack proper formatting.

Exam trap

The trap here is assuming that DATE_TRUNC or EXTRACT can directly produce a formatted string, when they return date or numeric types.

35
MCQmedium

A Data Engineer needs to transform semi-structured JSON data loaded into a VARIANT column named 'raw_data'. The goal is to flatten the 'items' array into individual rows while preserving the 'order_id' from the root level. Which function is the most efficient choice for this transformation?

A.JSON_EXTRACT_PATH_TEXT
B.FLATTEN
C.OBJECT_CONSTRUCT
D.ARRAY_TO_STRING
AnswerB

The FLATTEN function is the standard table function used to explode arrays or objects into separate rows. When applied with a LATERAL join, it maintains the relationship between the root object and the nested collection, providing the necessary tabular structure for further SQL-based data manipulation.

Why this answer

The FLATTEN function is specifically designed to transform semi-structured data into a relational format by producing a lateral view of array elements. By using it in a LATERAL join, the engineer can correlate the parent 'order_id' with each exploded array element effectively. This is a critical pattern in Snowflake for normalizing JSON structures before downstream analytics, ensuring that hierarchical data becomes queryable by standard SQL BI tools.

Exam trap

Engineers often try to use standard SQL joins or array functions without LATERAL, which fails to properly correlate root-level identifiers with exploded array elements.

36
Multi-Selectmedium

Which TWO statements describe the benefits of using Snowflake's 'Change Tracking' for data transformation?

Select 2 answers
A.It eliminates the need for primary keys on tables.
B.It allows for efficient incremental processing of only modified data.
C.It automatically cleans up stale data in the target table.
D.It reduces the amount of data processed in downstream tasks.
E.It is only available for tables in the Enterprise edition.
AnswersB, D

By only processing the rows that have changed (inserts, updates, or deletes), change tracking enables high-performance incremental transformations. This avoids the need to process the entire source table repeatedly, which would otherwise lead to excessive compute costs and increased latency in the data pipeline.

Why this answer

Change Tracking is the underlying mechanism that enables Streams. It allows Snowflake to record which rows were inserted, updated, or deleted, making incremental transformations possible. Instead of scanning entire tables to identify changes, the engine can simply query the stream, which significantly reduces compute time and costs for ETL processes.

This is critical for high-frequency data loading and incremental updates in modern data warehouses.

Exam trap

Test-takers frequently confuse change tracking with time travel or fail to select BOTH correct statements because they only focus on storage rather than downstream performance benefits.

37
MCQhard

A data engineer is working with a table that has a VARIANT column containing JSON objects. Some objects have a key 'discount' with a numeric value, while others have it as a string, and some lack the key entirely. The engineer needs to produce a numeric column 'discount_amount' where missing keys are treated as 0 and string values are cast to numbers. Which expression correctly achieves this?

A.COALESCE(TRY_TO_NUMBER(raw:discount), 0)
B.COALESCE(CAST(raw:discount AS NUMBER), 0)
C.COALESCE(TO_NUMBER(raw:discount), 0)
D.COALESCE(TRY_TO_NUMBER(raw:discount::STRING), 0)
AnswerA

This expression uses TRY_TO_NUMBER on the VARIANT value, which attempts to convert it to a number regardless of whether it is stored as a number or a string. If the conversion fails (e.g., missing key or non-numeric string), it returns NULL, and COALESCE replaces it with 0. This directly handles both numeric and string types and missing keys, making it the correct and efficient solution.

Why this answer

The correct expression uses TRY_TO_NUMBER to safely convert both numeric and string discount values to a number, returning NULL on failure, which COALESCE then replaces with 0. This handles missing keys and invalid strings without causing errors. The other options either use error-prone functions or unnecessary casting steps, making them less reliable for this transformation.

Exam trap

The trap here is using TO_NUMBER or CAST instead of TRY_TO_NUMBER, which can cause query failures when encountering non-numeric or missing values in semi-structured data.

38
MCQeasy

A data engineer needs to transform a string column containing dates in the format 'YYYY-MM-DD' into a DATE type. The column may contain NULL values and occasionally invalid date strings. The engineer wants the transformation to return NULL for invalid strings without causing the query to fail. Which function should the engineer use?

A.DATE
B.TO_DATE
C.TRY_TO_DATE
D.CAST
AnswerC

TRY_TO_DATE attempts to convert the string to a date and returns NULL if the conversion fails, rather than raising an error. This is ideal for handling invalid date strings gracefully. It also returns NULL for NULL inputs. The function is designed for exactly this scenario, where data quality is uncertain and you want to avoid query failures.

Why this answer

TRY_TO_DATE is specifically designed to return NULL instead of failing when a string cannot be converted to a date. This makes it the correct choice for transforming a column that may contain invalid date strings. TO_DATE and CAST would raise errors, and DATE is not a function.

The engineer should use TRY_TO_DATE to ensure the transformation completes successfully.

Exam trap

The trap here is assuming that TO_DATE or CAST will silently handle invalid dates, when in fact they raise errors and can break the pipeline.

39
MCQmedium

Which approach is most efficient for transforming a large volume of data in Snowflake when the logic requires complex window functions and stateful processing?

A.Using a Python script to fetch data, process locally, and upload.
B.Using a single Stored Procedure with row-by-row cursor processing.
C.Using set-based SQL transformations in a materialized view or dynamic table.
D.Using a User-Defined Function (UDF) for every column transformation.
AnswerC

Set-based transformations leverage Snowflake's query optimizer to execute complex logic in parallel across the cluster. This is the foundation of efficient ELT, as it pushes the transformation logic down to the data rather than moving data to the logic, maximizing performance and minimizing latency.

Why this answer

For large-scale, complex transformations, using SQL within a View, Dynamic Table, or a CTAS (Create Table As Select) operation is highly efficient because it runs directly on the Snowflake compute engine. Snowflake's query optimizer is highly tuned for window functions and complex joins, allowing it to distribute these operations across all nodes in the warehouse, providing superior performance compared to row-by-row procedural processing.

Exam trap

Candidates often try to use procedural code or UDFs for set-based operations. They overlook that native SQL set-based logic is inherently more optimized for distributed processing in Snowflake.

40
MCQmedium

A data engineer must transform semi-structured event data stored in a VARIANT column named 'event_payload'. The payload contains an array under the key 'tags', and each element of the array is an object with keys 'name' and 'score'. The engineer needs to produce one row per tag element, preserving the original event ID and extracting the 'name' and 'score' values. Which Snowflake construct should be used to achieve this transformation?

A.Use the FLATTEN function in the FROM clause with the INPUT argument set to event_payload:tags.
B.Use the SPLIT_TO_TABLE function with a delimiter of comma on the string representation of the tags array.
C.Use the PARSE_JSON function on event_payload:tags and then apply a lateral join with a VALUES clause.
D.Use the GET_PATH function to extract the array, then use a recursive CTE to iterate over its elements.
AnswerA

The FLATTEN table function is designed to explode semi-structured arrays into multiple rows. By specifying event_payload:tags as the INPUT, Snowflake returns one row per element in the array, allowing direct access to the 'name' and 'score' fields. This is the canonical way to transform nested arrays into a relational format while preserving the parent event ID.

Why this answer

Flattening a semi-structured array into rows is a core transformation in Snowflake. The FLATTEN table function directly expands array elements, producing one row per element and enabling easy extraction of nested fields. It preserves the parent row context, so the event ID remains available.

Other functions like PARSE_JSON or SPLIT_TO_TABLE do not achieve the same row expansion for VARIANT arrays.

Exam trap

The trap here is assuming that PARSE_JSON or SPLIT_TO_TABLE can flatten arrays, when only FLATTEN is designed for that purpose.

Ready to test yourself?

Try a timed practice session using only Data Transformation questions.