I have one table in snowflake with a column which contains a json blob. I want to flatten that column with a stored procedure. The issue is that I'd like to use the same stored procedure for different tables with different json schemas. In the example below the json consists of two key/value pairs. For another table there could be 5 key/value pairs which need to flatten.
Is it possible to do this with one stored procedure? If yes, how can I do that?
Original table
| Animal | Name | Details (json blob) |
|---|---|---|
| Lion | Georg | lion key1: value1, lion key2: value2 |
| Lion | Patrick | lion key1: value1, lion key2: value2 |
New table: Lion table
| Name | lion key1 | lion key2 |
|---|---|---|
| Georg | value1 | value2 |
| Patrick | value1 | value2 |
| Paul | value1 | value2 |