You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are getting errors when uploading the invocations.
DBT Version 1.3
dbt_artifacts version 2.2.2
Invoking dbt in the following way: dbt run --select mymodel -- vars '{"my_var": "my value"}' (or similar with dbt test, dbt seed, dbt build)
Which, when ran, gives the following error from BigQuery: Invalid input: syntax error while parsing object - invalid literal; last read: '"{"m'; expected '}'; error in PARSE_JSON expression
Which corresponds to the "vars": "{\"my_var\": \"my value\"}", which appears to be a correctly escaped json-string, but BigQuery will not accept it.
I propose to add custom handling for BigQuery (and other databases, if the problems exist there too), where we actually parse the invocation_args_dict.vars field, and convert it from a string to a proper python dictionary, before passing it to DBT's tojson.
Something along the lines of this in macros/upload_incovations.sql:
{% if invocation_args_dict.vars %}
{% set parsed_inv_args_vars = json.loads(invocation_args_dict.vars) %}
{% set invocation_args_dict.vars = parsed_inv_args_vars %}
{% endif %}
parse_json('{{ tojson(invocation_args_dict) }}'), {# invocation_args #}
But the --vars argument accepts any yaml dictionary, so all the following methods of invoking dbt are valid and equivalent:
dbt run --vars '{"key": "value", "date": 20180101}'
dbt run --vars '{key: value, date: 20180101}'
dbt run --vars 'key: value'
The text was updated successfully, but these errors were encountered:
I was a bit hasty on the pseudo-code above, which assumed that the vars was a proper json object, but the dbt docs states that it is a valid yaml object.
Hello,
We are getting errors when uploading the invocations.
DBT Version 1.3
dbt_artifacts version 2.2.2
Invoking dbt in the following way:
dbt run --select mymodel -- vars '{"my_var": "my value"}'
(or similar withdbt test
,dbt seed
,dbt build
)It produces the following SQL:
Which, when ran, gives the following error from BigQuery:
Invalid input: syntax error while parsing object - invalid literal; last read: '"{"m'; expected '}'; error in PARSE_JSON expression
Which corresponds to the
"vars": "{\"my_var\": \"my value\"}"
, which appears to be a correctly escaped json-string, but BigQuery will not accept it.I propose to add custom handling for BigQuery (and other databases, if the problems exist there too), where we actually parse the
invocation_args_dict.vars
field, and convert it from a string to a proper python dictionary, before passing it to DBT'stojson
.Something along the lines of this in
macros/upload_incovations.sql
:But the
--vars
argument accepts any yaml dictionary, so all the following methods of invoking dbt are valid and equivalent:The text was updated successfully, but these errors were encountered: