Fivetran connectors deliver data to your warehouse in a JSON format. However, the connectors only allow you to unpack one layer of columns.
In this article, find out how you can flatten the JSON fields below the first layer into their specific columns in your Snowflake warehouse.
Using Snowflake as your cloud warehouse.
In this example, Fivetran's Webhooks connector delivers JSON data to a column named DATA in your warehouse:
The JSON data is structured as:
"name": "John Smith"
"name": "Jane Doe"
To bring the user’s name and email fields into their own columns, set up a transformation to flatten the JSON into a view:
- Log in to your Fivetran account.
- Click Transformations.
- Click + Transformation.
- Enter a Name for your transformation.
In the SQL Script text box, add the following lines:
USE SCHEMA webhooks;
CREATE OR REPLACE VIEW users_unpacked AS (
value : name ::STRING as name ,
value :email::STRING as email,
lateral flatten( input => data :users)
- Choose your Schedule Type: New Data or Time Scheduled.
- Click Save and Run.
Once the transformation executes, it results in a newly created view in Snowflake: a row per user with the NAME and EMAIL columns.