我正在查询
SELECT event_params FROM public.events_20180626_temp where event_name='user_engagement';
并给出正确的答案,如下所示。
{"firebase_screen_class": "SplashScreenActivity", "firebase_event_origin": "auto", "firebase_screen_id": "7757319118664517009", "engagement_time_msec": "3804"}
{"firebase_screen_class": "BaseActivity", "firebase_event_origin": "auto", "firebase_screen_id": "-8308759841787556451", "engagement_time_msec": "5184"}
{"firebase_screen_class": "SplashScreenActivity", "firebase_event_origin": "auto", "firebase_screen_id": "5605799982713019219", "engagement_time_msec": "2976"}
{"firebase_screen_class": "CreateTaleActivity", "firebase_event_origin": "auto", "firebase_screen_id": "5605799982713019221", "engagement_time_msec": "46937"}
{"firebase_screen_class": "TaleLocationActivity", "firebase_event_origin": "auto", "firebase_screen_id": "5605799982713019223", "engagement_time_msec": "2952"}
{"firebase_screen_class": "TalePhotoEditorActivity", "firebase_event_origin": "auto", "firebase_screen_id": "5605799982713019228", "engagement_time_msec": "2295"}
{"firebase_screen_class": "BaseActivity", "firebase_event_origin": "auto", "firebase_screen_id": "5605799982713019220", "engagement_time_msec": "10664"}
当我更改查询以提取键“ engagement_time_msec”的值时,它说engagement_time_msec
在表中不存在。这是查询。
select json_extract_path_text(event_params, "engagement_time_msec") from public.events_20180626_temp where event_name='user_engagement';
通过下面的查询,我确认event_params
列中是否包含有效的json字符串。
select is_valid_json(event_params) from public.events_20180626_temp;
每行返回true
。
true
true
true
true
true
true
有人可以在这里帮助我吗?我是完全不熟悉Redshift的人。谢谢。
列event_params
的FYI数据类型为varchar(65553)
答案 0 :(得分:0)
弄清楚了。我要提取其值的键engagement_time_msec
必须使用单引号而不是双qoute。
select json_extract_path_text(event_params, 'engagement_time_msec') from public.events_20180626_temp where event_name='user_engagement';