fivetran / fivetran/dbt_fivetran_utils

`json_extract` should use double quotes on Snowflake

Open
#103 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
33
Forks
22
PR merge metrics
No merged PRs in 30d

Description

I'm using the Stripe package and have set project variables for fields I want to extract from `metadata` columns. It works on most values but isn't extracting anything when the key contains a full stop, e.g. `plan.id`.

I have fixed this locally by adding double quotes to the [Snowflake macro](https://github.com/fivetran/dbt_fivetran_utils/blob/cc2329a92fdaee11ea59fd8a7ce69e8b8fe8fe6c/macros/json_extract.sql#L15):
```
{% macro snowflake__json_extract(string, string_path) %}

json_extract_path_text(try_parse_json( {{string}} ), {{ "'\"" ~ string_path ~ "\"'" }} )

{% endmacro %}
```

Happy to make a PR but I'm not sure whether the problem applies to other databases.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.