sql - 我正在尝试通过 sql 访问雪花中的以下数据,但在列中获取 NULL。请调查一下
问题描述
下面是存储在表的一列中的数据(表:stg,col:LN)和我用来访问这些列的查询:
{"locations": [{"id": "893d7ef0", "name": "Organization", "type": "region"},
{"id": "7ad8787c", "name": "CORONA", "type": "st", "st_id": "1127"}]}
使用的查询是:
select * from(
select
replace(LN : locations.id , '"' , '')as loc_id,
replace(LN : locations.name , '"' , '') as loc_name,
replace(LN : locations.type , '"' , '') as loc_type,
replace(LN : locations.st_id , '"' , '') as loc_store_id
from db.schema.STG)
查询在列中给出 NULL,这就是问题所在。有什么建议么?
解决方案
你可以试试这个吗?
select
replace( j.value:id , '"' , '')as loc_id,
replace( j.value:name , '"' , '') as loc_name,
replace( j.value:type , '"' , '') as loc_type,
replace( j.value:st_id , '"' , '') as loc_store_id
from STG, table(flatten ( LN, path => 'locations' )) j;
推荐阅读
- javascript - 路口观察员不工作 Wordpress 5.8.1
- discord.py - Discord 按钮全部同时触发。不和谐.py
- apache-kafka - 通过 kafka-avro-console-producer 和融合模式注册表使用 RecordNameStrategy
- pgbouncer - 在 Apache 上使用 pgBouncer 和 PHP 脚本
- javascript - javascript: 因子 if 语句
- algorithm - O(n) 中加权树中的最大匹配
- php - 是否有一些简单的方法可以从表单(php)编辑最后一行数据
- azure - 在支持多个环境时,使用 Azure AD 的正确方法是什么?
- python - 如何在 Scikit-learn RandomForest 中获得训练精度?
- javascript - console.log 二叉树中的节点,其子树的总和为偶数