【问题标题】:RedShift: relation does not existRedShift:关系不存在
【发布时间】:2021-09-10 11:55:01
【问题描述】:

我在 RedShift 的“输入”列中有下一个数据:

[{"desc": "How many people does the video contain?", "name": "Number of People", "type": "dropdown", "values": ["", "Only 1", "2-3", "3+"]}, {"desc": "What is the camera position?", "name": "Movement", "type": "dropdown", "values": ["", "Fixed position", "Moving"]}, {"desc": "From which angle did you shoot the video?", "name": "Shoot Angle", "type": "dropdown", "values": ["", "Frontal recording", "Tight angle: 10-40 degree", "Wide angle: 40-70 degree"]}, {"desc": "From which distance did you shoot the video?", "name": "Distance", "type": "dropdown", "values": ["", "Near/Selfie", "Mid (3-6 ft)", "Far (>6 ft)"]}, {"desc": "What is the video lighting direction?", "name": "Lighting Direction", "type": "dropdown", "values": ["", "Front lit", "Side lit", "Back lit"]}, {"desc": "What is the video background?", "name": "Background", "type": "dropdown", "values": ["", "Outdoors", "In office", "At home", "Plain background"]}, {"desc": "What is the topic in your speech?", "name": "Topic", "type": "dropdown", "values": ["", "Arts and Media", "Business", "Education", "Entertainment", "Food/Eating", "Nutrition", "Healthcare ", "High School Life", "Mental Health", "News", "Technology", "Morals and Ethics", "Phones and Apps", "Sports", "Science"]}

“输入”不是“超级”类型的列。

所以,我需要将每个 dict 解析到每一行。

我尝试使用这个查询:

SELECT JSON_PARSE(c.inputs)::super AS jp, d.desc FROM appen_collect.staticprompts AS c, jp AS d WHERE prompttype = 'input' LIMIT 10;

但我得到一个错误:关系“jp”不存在。

不知道为什么……

【问题讨论】:

    标签: amazon-redshift


    【解决方案1】:

    可能需要格式化为子查询,试试下面:

    select d.desc
    from
    (
        select json_parse(inputs)::super as jp
        from appen_collect.staticprompts
        where prompttype = 'input'
    ) as c, jp as d
    limit 10;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-21
      • 2017-04-20
      • 2022-01-22
      • 2021-03-30
      • 2017-04-22
      • 2017-10-19
      • 2017-07-05
      相关资源
      最近更新 更多