CREATE MATERIALIZED VIEW
In this section, you will find information about BigQuery Materialized Views and their Snowflake equivalent.
Grammar Syntax
Click here to go to the BigQuery specification for this syntax.
Although Snowflake has the Materialized View
declaration, it has a series of limitations and aspects to take into account that make it behave differently from other database engines such as BigQuery, some of them are listed below.
Materialized View
is only available in the Enterprise edition.Data in
Materialized Views
are always being updated, which adds functional complexity to it.Materialized Views
are recommended when queries are small, in rows and columns.If the base table does not vary much, it is recommended to use
Materialized View
, otherwise aDynamic Table
.Dynamic Table
has fewer restrictions (some non-deterministic functions, and subqueries, among others, are allowed).
For more information, check this documentation and this comparison.
Given these reasons, the transformation of a BigQuery Materialized View
is done using a Dynamic Table
in Snowflake.
SnowConvert will convert all Materialized Views to Dynamic Tables. However, in specific cases, such as when you only have a base table with a few rows and columns, and the information is not so variable, it is possible to use a Materialized View. This process must be done manually.
Simple case
BigQuery
Snowflake
Snowflake Dynamic Table
has the TARGET_LAG
and WAREHOUSE
parameters which are mandatory, the first specifies the delay of the Dynamic Table
, for this parameter the default value will be 30 minutes since it is the same implemented for BigQuery Materialized View
. The second parameter specifies the name of the warehouse that provides the resources to update the Dynamic Table
. It is currently not possible to obtain this value automatically in SnowConvert, which is why an EWI is added. An alternative solution may be to use the CURRENT_WAREHOUSE
function.
Multiple tables
Note that the SELECT
statement incorporates multiple joins and accesses multiple tables. Snowflake Dynamic Table
has no limitations on this, so the transformation can be done without problems.
BigQuery
Snowflake
With Options clause
If the Create Materialized View has an options clause, this will be commented on since this is not supported in Snowflake
BigQuery
Snowflake
Known issues
1. Limitations
Snowflake and BigQuery have a list of limitations that must be taken into account, most of them are shared in both languages, such as the non-use non-deterministic functions. For more information check Snowflake documentation. and BigQuery documentation.
2. Materialized Views with subqueries are converted to regular Views
Snowflake Materialized Views support subqueries if they meet certain specifications. This scenario is currently not recognized, every Materialized View that has a subquery is converted to a regular view. For more information regarding this case, check this documentation.
3. The CLUSTER BY and PARTITION BY clauses
Dynamic Tables in Snowflake do not support clustering or partitioning, so these clauses do not apply to the conversion.
4. TARGET_LAG value
The value set for this parameter will follow the following laws:
Materialized View has no Options Clause ->
TARGET_LAG = 30 minutes
Options Clause has no Specific parameters (
enable_refresh
,refresh_interval_minutes
) ->TARGET_LAG = 30 minutes
enable_refresh = false
->TARGET_LAG = 30 minutes
enable_refresh = true && refresh_interval_minutes = null
->TARGET_LAG = 30 minutes
enable_refresh = true && refresh_interval_minutes = int
->TARGET_LAG = int minutes
enable_refresh = true && refresh_interval_minutes = float
->TARGET_LAG = ceilingFunction(float) minutes
Related EWIs
MSC-BQ0004: The OPTIONS clause within View is not supported in Snowflake.
MSCEWI1103: Materialized View was converted to Dynamic Table.
MSCEWI1104: TARGET_LAG is set to 1 day by default.
MSCEWI1105: WAREHOUSE set to a placeholder.
Last updated