Full command line for parameters vs. config file.
dataalias opened this issue · 3 comments
** What are you trying to accomplish? **
I have been able to successfully deploy sql scripts using schema change when taking advantage of the configuration file and executing the cli via subprocess.run
subprocess.run(["schemachange deploy --config-folder {}".format(CONFIG_FOLDER)],shell=True)
However, when running the script with explicitly listing each of the args:
subprocess.run(["schemachange deploy -f {} -a {} -u {} -r {} -w {} -d {} -s {} -c {}".format(
ROOT_FOLDER,dictSecrets['SFACCOUNT'],dictSecrets['SFSVCUSER'],
dictSecrets['SFROLE'],dictSecrets["SFWH"],os.environ["DATABASE"],
os.environ["SCHEMA"],os.environ["CHANGE_HISTORY"])],shell=True)
I run into the following error:
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 911, in main
deploy_command(config)
File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 517, in deploy_command
change_history_metadata = session.fetch_change_history_metadata(change_history_table)
File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 379, in fetch_change_history_metadata
results = self.execute_snowflake_query(query)
File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 373, in execute_snowflake_query
raise e
File "/usr/local/lib/python3.9/site-packages/schemachange/cli.py", line 366, in execute_snowflake_query
res = self.con.execute_string(query)
File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 817, in execute_string
ret = list(stream_generator)
File "/usr/local/lib/python3.9/site-packages/snowflake/connector/connection.py", line 835, 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 1132, 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: 000606 (57P03): No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command.
I have confirmed that the warehouse is indeed specified and a part of the snowflake connection.
** What options have you tried so far ? **
I have just gone into the cli.py to trace and see that all the args I added to the command line are available to the cli. For instance:
print(self.con.warehouse)
shows the expected warehouse. And I have tested the query with the same role and warehouse in snowflake and received the expected results:
SELECT CREATED, LAST_ALTERED FROM DEV.INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = REPLACE('PIPELINE','"','') AND TABLE_NAME = replace('CHANGE_HISTORY','"','')
Any suggestions welcome :-)
Thanks!
Having the same problem for the last couple of days
+1 Having the same issue on version 3.4.2, so we have not even updated to latest. Is there a workaround in place?
Whelp, my shame knows no bounds. I had transposed Snowflake Access and Functional Role names when calling the schema change CLI.
For instance:
SF Warehouse : PIPELINE_WH
SF Database : DEV
SF User : PIPELINE_DEV_USER
SF ROLE, Functional : PIPELINE_DEV
SF ROLE, Access : PIPELINE_DEV_ACCESS
Only the functional role PIPELINE_DEV had access to warehouse PIPELINE_WH. In the command line I provided the access role PIPELINE_DEV_ACCESS. It doesn't have access to the warehouse so I ran into the failure. I was able to test this and see the error by using a snowflake work sheet.
- When choosing the role PIPELINE_DEV I have the option to select warehouse PIPELINE_WH
- When choosing the role PIPELINE_DEV_ACCESS I do not have the option to select warehouse PIPELINE_WH
Hope this helps others. Check your snowflake roles.