snowflake-cloud-data-platformsnowsql

is there a way to put comments in SnowSQL files that do not cause errors?


I'm using files with snowsql to automate certain processes. For maintenance, I want to include comments in the file (using // at the start of the line) to explain key steps. However, when I do this snowsql reports an error: 000900 (42601): SQL compilation error: Empty SQL statement.

for example:

select 'hello world';
// and now exit the session
!exit

will cause the error:

$ snowsql --filename comments.sql
* SnowSQL * v1.2.5approval |                     
Type SQL statements or !help                     
+---------------+                                
| 'HELLO WORLD' |                                
|---------------|                                
| hello world   |                                
+---------------+                                
1 Row(s) produced. Time Elapsed: 0.209s          
000900 (42601): SQL compilation error:           
Empty SQL statement.                             
Goodbye!                                         

If I remove the comments and leave empty lines instead:

select 'hello world';

!exit

Then it works with no errors reported

$ snowsql --filename no-comments.sql
* SnowSQL * v1.2.5approval |
Type SQL statements or !help
+---------------+
| 'HELLO WORLD' |
|---------------|
| hello world   |
+---------------+
1 Row(s) produced. Time Elapsed: 1.088s

Goodbye!

This occurs with snowsql version 1.2.5

Is there a way to include comments in sql file that does not cause errors in snowsql?


Solution

  • You can use the standard SQL comment markers, double dashes. I tested it and it works:

    select 'hello world';
    -- and now exit the session
    !exit
    

    I think that if it works in the web UI it should work the same way in SnowSQL, so I'll open a ticket to check on this.