我在表中有一个 json 对象列(使用 redshift 作为我们的数据仓库),其中包含 Web 事件属性:
{
"Page URL":"http://foo.bar/some-utm-properties",
"discount_code":"some discount code",
"eventSource":"fooevent",
"uniqueId":"1234xyz",
"referringDomain":"foobar.com",
}
我正在尝试从对象中提取键“Page URL”的值。我可以编写一个查询,返回不包含空格的其他键的值,但是我无法弄清楚这个。
下面是我编写的查询,它对其他键成功,但对“页面 URL”不成功
with parse as (
select
event_properties,
json_parse(event_properties) as event_prop_json
from web_event
)
select
event_prop_json.["Page URL"] as page_url,
event_prop_json.["discount_code"] as discount_code
from parse
通过对上述对象的查询,我得到以下结果:
A 栏 | B 栏 |
---|---|
空 | “一些折扣代码” |
我尝试了各种配置查询语句的方法( event_prop_json.[""Page URL""], event_prop_json.["\"Page URL\""], event_prop_json."Page URL", event_prop_json.'"Page URL" '等)一些有错误,另一些也返回 NULL。任何帮助将不胜感激!
你确定是空间吗? 我怀疑是大写字母。 默认情况下,Redshift 不区分大小写(转换为小写),但在处理超级键时,它会将所有内容转换为小写。
尝试打开区分大小写:
SET enable_case_sensitive_identifier TO true;
但是,这会为所有表和列引用启用区分大小写,因此您可能需要修改某些查询或在需要区分大小写的查询周围打开和关闭此选项。