The following statements on SQL are tagged to track consumption:
Statements
HiveSQL
SparkSQL
SnowSQL
The FUNCTIONAL EQUIVALENT status only covers scenarios where the comment is transformed to Snowflake. Other statements contained are not considered on this status.
Usages
The following statements are identified and tagged by the tool:
CREATE STATEMENTS
The CREATE statements will have the tag in two possible scenarios:
The statement does not contain the COMMENT property.
The statement contains the COMMENT property but its value is empty.
If the statement already contains a comment, this one will be preserved.
Example
Input (SparkSQL)
CREATE OR REPLACEVIEWsome_viewASSELECT id, nameFROM some_table WHERE some_column >5;CREATE OR REPLACEFUNCTIONblue()RETURNS STRINGLANGUAGESQLCOMMENT ''RETURN'0000FF'; CREATETABLEmy_varchar ( COL1 VARCHAR(5)) COMMENT 'The Table';
Output (Snowflake SQL)
CREATE OR REPLACEVIEWsome_viewCOMMENT = '{"origin":"sf_sit","name":"sma","version":{"major":1,"minor":2,"patch":3},"attributes":{"language":"HiveSql"}}'
ASSELECT id,nameFROM some_tableWHERE some_column >5;CREATE OR REPLACEFUNCTIONblue()RETURNS STRING LANGUAGESQLCOMMENT = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"SparkSql"}}'
RETURN'0000FF';CREATETABLEmy_varchar(COL1 VARCHAR(5))COMMENT ='The Table';
The indentation of the output code may change due to the original format of the source code.
CREATE OR REPLACEVIEWexperienced_employeeASSELECT id, nameFROM all_employeeWHERE working_years >5;
Output code (Snowflake SQL)
CREATE OR REPLACEVIEWexperienced_employeeCOMMENT = '{"origin":"sf_sit","name":"sma","version":{"major":1,"minor":2,"patch":3},"attributes":{"language":"HiveSql"}}'
ASSELECT id,nameFROM all_employeeWHERE working_years >5;
Create Function
Input code (SparkSQL)
CREATE OR REPLACEFUNCTIONblue()RETURNS STRINGLANGUAGESQLRETURN'0000FF';
Output (Snowflake SQL)
CREATE OR REPLACEFUNCTIONblue()RETURNS STRINGLANGUAGESQLCOMMENT = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"SparkSql"}}'
RETURN'0000FF';
ALTER STATEMENTS
The ALTER statements will have the tag when the comment property comes empty. There are two ways that comment clause comes empty, one is in SET TBLPROPERTIES and the other UNSET TBLPROPERTIES (in case of SparkSql) .
Examples
SET TBLPROPERTIES (Alter View and Alter Table)
Input (SparkSql)
-- ALTER TABLEALTERTABLE SOME_TABLE SET TBLPROPERTIES ('comment'=' ');-- ALTER VIEWALTERVIEW SOME_VIEW SET TBLPROPERTIES ('comment'=' ');
Output (Snowflake SQL)
-- ALTER TABLEALTERTABLE SOME_TABLESET TBLPROPERTIES ('comment' = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"SparkSql"}}');
-- ALTER VIEWALTERVIEW SOME_VIEWSET TBLPROPERTIES ('comment' = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"SparkSql"}}');
Input (HiveSql)
-- ALTER TABLEALTERTABLE SOME_TABLE SET TBLPROPERTIES ('comment'=' ');-- ALTER VIEWALTERVIEW SOME_VIEW SET TBLPROPERTIES ('comment'=' ');
Output (Snowflake SQL)
-- ALTER TABLEALTERTABLE SOME_TABLESET TBLPROPERTIES ('comment' = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"HiveSql"}}');
-- ALTER VIEWALTERVIEW SOME_VIEWSET TBLPROPERTIES ('comment' = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"HiveSql"}}');
UNSET TBLPROPERTIES (Alter View and Alter Table)
Input (SparkSql)
-- ALTER TABLEALTERTABLE SOME_TABLE UNSET TBLPROPERTIES ('comment');-- ALTER VIEWALTERVIEW SOME_VIEW UNSET TBLPROPERTIES ('comment');
Output (Snowflake SQL)
-- ALTER TABLEALTERTABLE SOME_TABLEUNSET TBLPROPERTIES ('comment')ALTERTABLE SOME_TABLESET COMMENT = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"SparkSql"}}'
-- ALTER VIEWALTERVIEW SOME_VIEWUNSET TBLPROPERTIES ('comment')ALTERVIEW SOME_VIEWSET COMMENT = '{"origin":"sf_sit","name":"sma","version":{"major":0,"minor":0,"patch":0},"attributes":{"language":"SparkSql"}}'