schemachange icon indicating copy to clipboard operation
schemachange copied to clipboard

Getting "unexpected '<EOF>'" error when trying to deploy migrations on gitlab

Open carley-citian opened this issue 1 year ago • 9 comments

Describe the bug Hi! I am getting the following error everytime I try to run my Gitlab CI/CD pipeline with schemachange on a new SQL migrations file:

Traceback (most recent call last):
  File "/usr/local/bin/schemachange", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 896, in main
    deploy_command(config)
  File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 577, in deploy_command
    session.apply_change_script(script, content, change_history_table)
  File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 462, in apply_change_script
    self.execute_snowflake_query(script_content)
  File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 367, in execute_snowflake_query
    raise e
  File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 360, in execute_snowflake_query
    res = self.con.execute_string(query)
  File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 792, in execute_string
    ret = list(stream_generator)
  File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 810, in execute_stream
    cur.execute(sql, _is_put_get=is_put_or_get, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/snowflake/connector/cursor.py", line 920, in execute
    Error.errorhandler_wrapper(self.connection, self, error_class, errvalue)
  File "/usr/local/lib/python3.9/site-packages/snowflake/connector/errors.py", line 290, in errorhandler_wrapper
    handed_over = Error.hand_to_other_handler(
  File "/usr/local/lib/python3.9/site-packages/snowflake/connector/errors.py", line 345, in hand_to_other_handler
    cursor.errorhandler(connection, cursor, error_class, error_value)
  File "/usr/local/lib/python3.9/site-packages/snowflake/connector/errors.py", line 221, in default_errorhandler
    raise error_class(
snowflake.connector.errors.ProgrammingError: 001003 (42000): SQL compilation error:
syntax error line 9 at position 17 unexpected '<EOF>'.

I have tested the same exact code in a worksheet on Snowflake and can confirm it works. I also have run migration files that worked on my pipeline before, but recently this error is popping up for every file I try to run on the pipeline.

Here are the final few lines of my file for context -- there should be no issue with the code:

-- ops_admin
GRANT ALL ON ALL TABLES IN SCHEMA skeleton_basedata TO role ops_admin;
GRANT all ON ALL SEQUENCES IN SCHEMA skeleton_basedata TO role ops_admin;
GRANT all on FUNCTION skeleton_basedata.st_union_agg(ARRAY) TO role ops_admin;
GRANT all ON PROCEDURE skeleton_basedata.get_nearby_basedata(double precision, double precision, double precision) TO role ops_admin;
GRANT all ON ALL DYNAMIC TABLES IN SCHEMA skeleton_basedata TO role ops_admin;
GRANT all ON ALL VIEWS IN SCHEMA skeleton_basedata TO role ops_admin;

To Reproduce Steps to reproduce the behavior:

  1. Commit the above sql code as a migration
  2. Run pipeline
  3. Scroll down to log where schemachange is attempting to execute code
  4. See error

Expected behavior Expected behavior would be that the code changes are run on snowflake this step, and committed.

Schemachange (please complete the following information):

  • Version : 3.6.1

Additional context Here is the query tag given to my run: SQL query: ALTER SESSION SET QUERY_TAG = 'schemachange 3.6.1;V1.0.3__skeleton_basedata_schema.sql'

Also here is a screenshot of the error I am getting in the log, seems like the trailing semicolon is getting cut off for some reason if that is helpful?: Screenshot 2023-11-17 at 5 26 19 PM

I have been committing the changes manually on Snowflake worksheets for now, but would love to get my pipeline up and working again soon if anyone can help!

carley-citian avatar Nov 17 '23 22:11 carley-citian