Snowflake Dynamic Tables VS Streams & Tasks VS Materialized Views

Confused about dynamic tables? How they are different from Streams and tasks or from Materialized views? Let’s discuss more on the comparison.

Executive Summary:

  1. Streams and Tasks
  2. Dynamic Tables
  3. Materialized Views

Snowflake Streams and Tasks for Continuous Data Pipeline:

Although dynamic tables serve a similar purpose as tasks, there are important differences:

  • Tasks use an imperative approach where you write procedural code to transform data from base tables.
  • Then you define the schedule for executing that code to transform the data.
  • The code can contain calls to non-deterministic code, stored procedures, UDFs, external functions, and other tasks.
  • Tasks can use streams to refresh data in target tables incrementally. You can schedule these tasks to run on a regular basis.
Reference Image from Snowflake

Snowflake Dynamic Tables for Continuous Data Pipeline

Dynamic tables are the declarative approach when compared with the Tasks and streams.

  • You write a query that specifies the result you’d like to see, and data is retrieved and transformed from the base tables used in the query.
  • An automated refresh process determines the schedule for performing these refreshes.
  • The process schedules these refreshes to meet the specified target level of freshness.
  • Although the SELECT statement for a dynamic table can contain joins, aggregations, window functions, and other SQL functions and constructions, the statement cannot contain calls to stored procedures, UDFs, external functions, and tasks. This limitation is due to how dynamic tables are refreshed and the non-deterministic codes prevent this.
  • An automated refresh process performs incremental refreshes of dynamic tables on a regular basis. The process determines the schedule, based on a target “freshness” or LAG of the data that you specify.
Reference Image from Snowflake

Dynamic Tables VS Materialized Views:

  • Materialized views are designed to transparently improve query performance while Dynamic Tables are designed to transform streaming data in a data pipeline.
  • A materialized view can only use a single base table while a dynamic table can be based on a complex query that can include joins and unions.
  • Data accessed through materialized views is always current while the data is current up to the target lag time for the dynamic table.

Dynamic tables have some similarities to materialized views in that both materialize the results of a query.

About Me:

Hi there! I am Divyansh Saxena

I am an experienced Data Engineer with a proven track record of success in Snowflake Data Cloud technology. Highly skilled in designing, implementing, and maintaining data pipelines, ETL workflows, and data warehousing solutions. Possessing advanced knowledge of Snowflake’s features and functionality, I work at IBM and am a Snowflake Data superhero & Snowflake Snowpro Core SME. With a major career in Snowflake Data Cloud, I have a deep understanding of cloud-native data architecture and can leverage it to deliver high-performing, scalable, and secure data solutions.

Follow me on Medium for regular updates on Snowflake Best Practices and other trending topics:

Also, I am open to connecting all data enthusiasts across the globe on LinkedIn:

https://www.linkedin.com/in/divyanshsaxena/

--

--