如何将字典列表数据转换为字典字典,其中键是 Snowflake 中内部字典的值之一
如何将字典列表数据转换为字典字典,其中键是 Snowflake 中内部字典的值之一。
上下文:我想要转换的值位于表格的单元格中,我试图用转换后的格式替换该单元格。
我试图通过两种方式找到完成上述任务的方法。 1.SnowflakeSQL 2.Javascript UDF 这是表中某个单元格中的值。
[
{
"Vehicle_type": "P",
"Vehicle_year": "2022",
"KEY": "key_98765"
},
{
"Vehicle_type": "Q",
"Vehicle_year": "2019",
"KEY": "key_12345"
}
]
我希望将其转换为
{
'key_98765':
{
"Vehicle_type": "P",
"Vehicle_year": "2022",
"KEY": "key_98765"
},
'key_12345':
{
"Vehicle_type": "Q",
"Vehicle_year": "2019",
"KEY": "key_12345"
}
}
How to transform a data which is list of dictionaries to a dictionary of dictionaries with key being one of the value in inner dicts in Snowflake.
Context: The values I want to transform are in a cell of a table, i am trying to replace that cell with a transformed format.
I am trying to find ways to the task above in two ways. 1. SnowflakeSQL 2. Javascript UDF
This is a value in one of the cells in a table.
[
{
"Vehicle_type": "P",
"Vehicle_year": "2022",
"KEY": "key_98765"
},
{
"Vehicle_type": "Q",
"Vehicle_year": "2019",
"KEY": "key_12345"
}
]
I want this to be transformed to
{
'key_98765':
{
"Vehicle_type": "P",
"Vehicle_year": "2022",
"KEY": "key_98765"
},
'key_12345':
{
"Vehicle_type": "Q",
"Vehicle_year": "2019",
"KEY": "key_12345"
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以这样做:
脚本
You can do it like this:
script