SQL错误[500310] [42703]:[Amazon](500310)无效的操作:events_20180626_temp中不存在列“ engagement_time_msec”;

时间:2019-12-05 10:42:07

标签: sql json database amazon-redshift

我正在查询

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)

1 个答案:

答案 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';