Translation reference to convert Teradata VIEW statement to Snowflake
Description
Teradata's VIEW statement is translated to Snowflake VIEW syntax.
For more information on Teradata VIEW, check here.
Sample Source Patterns
Create View Transformation
Teradata
CREATEVIEWview1 (someTable.col1, someTable.col2) AS locking rowfor accessSELECT my_table.col1, my_table.col2FROM table1 AS my_tableWHERE my_table.col1 ='SpecificValue'UNION ALLSELECT other_table.col2FROM table2 AS other_tableWHERE my_table.col2 = other_table.col2)
Snowflake
CREATE OR REPLACEVIEWPUBLIC.view1 (col1, col2)ASSELECT my_table.col1, my_table.col2FROM PUBLIC.table1 AS my_tableWHERE my_table.col1 ='SpecificValue'UNION ALLSELECT PUBLIC.other_table.col2FROM table2 AS other_tableWHERE my_table.col2 = other_table.col2
Custom Schema Tag
The custom schema is specified in the comment section before the specification of the view, with an XML tag named “sc-view” that contains only the value of the schema and the view name separated with a period ‘.’ as shown below: <sc-view>SCHEMANAME.VIEWNAME</sc-view>
The custom schema will be used as a view qualifier, and then the name of the view and all the objects referred to in the FROM queries and inner queries will be using that custom schema. Therefore could be several views with the same name, but with different custom tags. Example: two views with the same name, will take the custom schema tag information to perform the translation.
Teradata
/*<sc-view>RMSviews.EMPLOYEEB</sc-view>*/REPLACE VIEW EMPLOYEEB ASSELECT*FROM EMPLOYEEWHERE AREA ="AREAB";/*<sc-view>Views.EMPLOYEEB</sc-view>*/REPLACE VIEW EMPLOYEEB ASSELECT*FROM EMPLOYEEWHERE AREA ="AREAB";
Snowflake
The transformation for Snowflake will vary depending on the customized schema name MySchema, customized database name MyDatabase or not selecting a customized database or schema in the conversion settings.
/*<sc-view>RMSviews.EMPLOYEEB</sc-view>*/CREATE OR REPLACEVIEWRMSviews.MySchema.EMPLOYEEBASSELECT*FROM RMSviews.MySchema.EMPLOYEEWHERE AREA ="AREAB";/*<sc-view>Views.EMPLOYEEB</sc-view>*/CREATE OR REPLACEVIEWViews.MySchema.EMPLOYEEBASSELECT*FROM Views.MySchema.EMPLOYEE;
/*<sc-view>RMSviews.EMPLOYEEB</sc-view>*/CREATE OR REPLACEVIEWMyDatabase.RMSviews.EMPLOYEEBASSELECT*FROM MyDatabase.RMSviews.EMPLOYEEWHERE AREA ="AREAB";/*<sc-view>Views.EMPLOYEEB</sc-view>*/CREATE OR REPLACEVIEWMyDatabase.Views.EMPLOYEEBASSELECT*FROM MyDatabase.Views.EMPLOYEEWHERE AREA ="AREAB";
/*<sc-view>RMSviews.EMPLOYEEB</sc-view>*/CREATE OR REPLACEVIEWRMSviews.PUBLIC.EMPLOYEEBASSELECT*FROM RMSviews.PUBLIC.EMPLOYEEWHERE AREA ="AREAB";/*<sc-view>Views.EMPLOYEEB</sc-view>*/CREATE OR REPLACEVIEWViews.PUBLIC.EMPLOYEEBASSELECT*FROM Views.PUBLIC.EMPLOYEEWHERE AREA ="AREAB";
Known Issues
1. Locking row for access unsupported
AS locking row for access is removed as shown in the example "Create View Transformation".