MSC-BQ0008
Javascript code has not been validated
This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.
Severity
High
Description
SnowConvert does not transform Javascript code. Since the Javascript code extracted from BigQuery's functions hasn't been changed at all, this code might need some tweaks to work on Snowflake.
Code Example
Input Code
CREATE FUNCTION test.languageJs (x integer, y integer)
RETURNS integer
LANGUAGE js
AS "return x * y;";
Output Code
CREATE OR REPLACE FUNCTION languageJs (x DOUBLE, y DOUBLE)
RETURNS DOUBLE
LANGUAGE JAVASCRIPT
--** MSC-ERROR - MSC-BQ0008 - JAVASCRIPT CODE HAS NOT BEEN VALIDATED. **
AS
$$
return x * y;
$$;
Recommendations
Review your named window definitions, it might be possible to take the definition and apply it to the
OVER
clause of the functions it is used in. However, keep in mind the functional differences between BigQuery and Snowflake window frames still apply, take the following case as an example:
BigQuery:
SELECT SUM(col1) OVER(myWindow) FROM test.exampleTable WINDOW myWindow AS (ORDER BY col2);
Snowflake:
SELECT SUM(col1) OVER(ORDER BY col2) FROM exampleTable;
These two queries will produce the same rows but the Snowflake results will not be ordered, this is because the ORDER BY
clause for window frames does not impact the entire query ordering as it does in BigQuery.
Recommendations
Review all Javascript code before deployment.
Javascript parameters in Snowflake must be uppercase.
The above example would work in Snowflake just by changing the case of
x
andy
.
CREATE OR REPLACE FUNCTION languageJs (x DOUBLE, y DOUBLE)
RETURNS DOUBLE
LANGUAGE JAVASCRIPT
--** MSC-ERROR - MSC-BQ0008 - JAVASCRIPT CODE HAS NOT BEEN VALIDATED. **
AS
$$
return X * Y;
$$;
For more information, visit Snowflake's Introduction to Javascript UDFs.
If you need more support, you can email us at [email protected]
Last updated