Snowflake-Labs / schemachange

A Database Change Management tool for Snowflake
Apache License 2.0
481 stars 219 forks source link

Schemachange render: error: argument --vars: invalid loads value: '{variable1: value1, variable2: value2}' #202

Closed lgc-jacovanwyk closed 2 months ago

lgc-jacovanwyk commented 8 months ago

For the life of me, I cannot work out how to pass these variables? I run the following: schemachange render -a XXX.eu-west-1 -u XXX -r XXX -w XXX --vars '{"variable1": "value1", "variable2": "value2"}' But repeatedly getting this error back: schemachange render: error: argument --vars: invalid loads value: '{variable1: value1, variable2: value2}'

I've lifted the variables as is from the documentation. Is this a bug?

sfc-gh-tmathew commented 8 months ago

When using the render command, you do not need the options used for deploy.

When I run your command using 3.6.0, I get the following message

usage: schemachange [-h] {deploy,render} ...
schemachange: error: unrecognized arguments: -a -u XXX -r XXX -w XXX

For example, run the help command to see the options expected for the render command

schemachange render -h

Here is a sample file that have in my folder say R__test.sql

SET MY_VARIABLE = {{ my_value }}
SET MY_VARIABLE2 = {{ my_second_value }}

If I run the command to render the variables

schemachange render --vars '{"my_value":"foobar", "my_second_value":"foobar2"}' ./*

Output shown below (With some output truncated or obfuscated)

schemachange version: 3.6.0
Using root folder /Users/<user>/repos/schemachange-demo
Using variables:
  my_value: foobar
  my_second_value: foobar2

Checksum 1bd96...b781aedc
SET MY_VARIABLE = foobar
SET MY_VARIABLE2 = foobar2

I checked this with 3.5.3 and 3.6.0 and we have the same behavior via zsh shell.

@lgc-jacovanwyk: Please confirm if you are able to render the scripts by using the expected syntax.

pravinwadikar commented 6 months ago

Please use --var "{""variable1"": ""value1"", ""variable2"": ""value2""}". It will work.

sfc-gh-tmathew commented 2 months ago

This works as designed. Closing the issue