Combination of Questionnaire Questions and Answers

The obtained question and answer are in json format, and the fields are map<string,string>. It is necessary to separate the serial number from the following questions or answers, and adopt the method of lateral view explode. Compared with explode, lateral view explode can select non-exploded fields

It should be noted that there are no brackets in the two fields after the explosion. If there is where, where is placed at the end

	select q_key, q_value
	from questionnaire
	lateral view explode(questions) t as q_key, q_value

You can use lateral view explode multiple times

  select q_key, q_value, a_key, a_value
  from questionnaire
  lateral view explode(questions) t as q_key, q_value
  lateral view explode(answers) t2 as a_key, a_value
  where q_key=a_key  

Guess you like

Origin blog.csdn.net/weixin_43955488/article/details/126162560