-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schemachange is failing when we have any comments in the code #130
Comments
Hey there @praneeth1987, thanks for bringing this up. I'm not sure what the right fix is here. If we add remove_comments=True to the execute_string() call then all comments in the script will be removed. Some customers rely on comments in their queries for various reasons. The problem appears to be having a comment on the last line of the script: https://community.snowflake.com/s/article/Comments-causes-SQL-compilation-error-Empty-SQL-statement. I would suggest just removing that from the script. Are you using source control? In general it's a best practice to not check in/commit code with comments and source control would help you keep the version history in case you needed to revert at some point. Just a thought. |
This caught me for a while too as I was using a comment at the end of my scripts: |
Hello @praneeth1987 As suggested above the workaround is to avoid comments in the last line of the SQL file. We do not plan to fix this anytime soon. We cannot strip comments for reasons stated earlier. Therefore, closing the issue for now. |
This link is now a 404, is there an updated link to explain why SQL statements cannot end with a comment? |
I have below sql file which needs to be deployed
create table --------;
//alter table
After testing in DEV, I no longer need alter table command.
I have commented out alter table command while promoting to TEST & PROD , but it is failing with below error
snowflake.connector.errors.ProgrammingError: 000900 (42601): SQL compilation error:
Empty SQL statement.
As per this https://community.snowflake.com/s/article/Empty-SQL-Statement-When-Through-Python-Code-When-We-Have-Commented-Lines-In-the-Code-File
We need to use the set remove_comments=True,
Do you have any alternative for this or is this known issue?
The text was updated successfully, but these errors were encountered: