Additionally, a couple other parts are partially supported, and require additional work to be implemented in order to properly emulate the original functionality. Specifically, we're talking about the MASKED WITH property, which will be covered in the patterns section of this page.
Since the collation rule nomenclature varies from SQL Server to Snowflake, it is necessary to make adjustments.
Snowflake
OUT -> SqlServer_02.sql
ALTERTABLEIFEXISTS table_nameADD COLUMN new_column_name VARCHAR COLLATE 'EN-CI-AS' /*** SSC-PRF-0002 - CASE INSENSITIVE COLUMNS CAN DECREASE THE PERFORMANCE OF QUERIES ***/;
MASKED WITH
This pattern showcases the translation for MASKED WITH property. CREATE OR REPLACE MASKING POLICY is inserted somewhere before the first usage, and then referenced by a SET MASKING POLICY clause.
The name of the new MASKING POLICY will be the concatenation of the name and arguments of the original MASKED WITH FUNCTION, as seen below:
!!!RESOLVE EWI!!! /*** SSC-EWI-TS0057 - MASKING ROLE MUST BE DEFINED PREVIOUSLY BY THE USER ***/!!!CREATEORREPLACE MASKING POLICY"random_1_999"AS(val SMALLINT)RETURNSSMALLINT->CASEWHEN current_role() IN ('YOUR_DEFINED_ROLE_HERE')THEN valELSE UNIFORM(1, 999, RANDOM()) :: SMALLINTEND;ALTER TABLE IF EXISTS table_name MODIFY COLUMN column_name!!!RESOLVE EWI!!! /*** SSC-EWI-TS0056 - A MASKING POLICY WAS CREATED AS SUBSTITUTE FOR MASKED WITH ***/!!! SET MASKING POLICY "random_1_999";
DEFAULT
This pattern showcases some of the basic translation scenarios for DEFAULT property.
ALTERTABLEIFEXISTS table2ADD column1 VARBINARY(max)!!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!!FILESTREAM;
SPARSE
In SQL Server, SPARSE is used to define columns that are optimized for NULL storage. However, when we're using Snowflake, we are not required to use this clause.
Snowflake performs optimizations over tables automatically, which mitigates the need for manual user-made optimizations.
SQL Server
IN -> SqlServer_09.sql
-- ADD COLUMN DEFINITION formALTERTABLE table3ADD column1 intNULL SPARSE;----------------------------------------/* It also applies to the other forms */------------------------------------------ CREATE TABLE formCREATETABLEtable3( column1 INT SPARSE NULL);-- ALTER COLUMN formALTERTABLE table3ALTER COLUMN column1 INTNULL SPARSE;
Snowflake
OUT -> SqlServer_09.sql
-- ADD COLUMN DEFINITION formALTERTABLEIFEXISTS table3ADD column1 INTNULL !!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!! SPARSE;----------------------------------------/* It also applies to the other forms */------------------------------------------ CREATE TABLE formCREATE OR REPLACETABLEtable3( column1 INT !!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!! SPARSE NULL)COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"transact"}}'
;-- ALTER COLUMN formALTERTABLEIFEXISTS table3ALTER COLUMN column1 !!!RESOLVE EWI!!! /*** SSC-EWI-TS0061 - ALTER COLUMN COMMENTED OUT BECAUSE SPARSE COLUMN IS NOT SUPPORTED IN SNOWFLAKE ***/!!!
INTNULL SPARSE;
ALTERTABLEIFEXISTS table_nameADD column_name VARCHAR!!!RESOLVE EWI!!! /*** SSC-EWI-0040 - THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/!!!ROWGUIDCOL;
Known Issues
1. Roles and users have to be previously set up for masking policies
Snowflake's Masking Policies can be applied to columns only after the policies were created. This requires the user to create the policies and assign them to roles, and these roles to users, in order to work properly. Masking Policies can behave differently depending on which user is querying.
SnowConvert does not perform this setup automatically.
2. Masking policies require a Snowflake Enterprise account or higher.
higher-rankThe Snowflake documentation states that masking policies are available on Entreprise or higher rank accounts.
SQL Server's DEFAULT property is partially supported by Snowflake, as long as its associated value is a constant.
4. FILESTREAM clause is not supported in Snowflake.
The entire FILESTSTREAM clause is commented out, since it is not supported in Snowflake.
5. SPARSE clause is not supported in Snowflake.
The entire SPARSE clause is commented out, since it is not supported in Snowflake. When it is added within an ALTER COLUMN statement, and it's the only modification being made to the column, the entire statement is removed since it's no longer adding anything.