How to create a materialized view with a view definition of flattening nested json
Hi there - I am trying to create a materialized view to improve performance of a query in snowflake by splitting the json field in a table into structured columns. Since materialized views allow only single table in the definition, am not able to move forward. My JSON contains nested json values as shown in the below sample query. I have orders and each order will have corresponding items in the line items node within a json. Please let me know if there is a workaround to achieve this.
CREATE OR REPLACE MATERIALIZED VIEW Test
AS
SELECT JSON:orderNumber::VARCHAR as order_number
FROM orderitem o,
TABLE(flatten(json:lineItems)) items
,items.value:id::VARCHAR as item_id
nekkanti009
posted on 26 Dec 19Enjoy great content like this and a lot more !
Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds
Post Comment