복붙노트

[HADOOP] HIVE에서 JSON 문제

HADOOP

HIVE에서 JSON 문제

테이블 SRC (myjson 문자열)을 생성;

insert into src values {"Rtype":{"ver":"1","os":"ms","type":"ns","vehicle":"Mh-3412","MOD":{"Version":[{"ABC":{"XYZ":"123.dfer","founder":"3.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"},{"XYZ":"123.dfer","founder":"2.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"},{"XYZ":"123.dfer","founder":"7.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"}}]}}} US 123

{"Rtype":{"ver":"1","os":"ms","type":"ns","vehicle":"Mh-3412","MOD":{"Version":[{"ABC":{"XYZ":"123.dfer","founder":"3.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"},{"XYZ":"123.dfer","founder":"3.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"},{"XYZ":"123.dfer","founder":"3.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"}}]}}} CAV 12673


{"Rtype":{"ver":"1","os":"ms","type":"ns","vehicle":"Mh-3412","MOD":{"Version":[{"ABC":{"XYZ":"123.dfer","founder":"3.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"},{"XYZ":"123.dfer","founder":"3.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"},{"XYZ":"123.dfer","founder":"3.0","GHT":"Florida","fashion":"fg45","cdc":"new","dof":"yes","ts":"2000-04-01T00:00:00.171Z"}}]}}} XR 123sd2

아래 그림과 같이 선택하는 동안 내가 데이터를 원하는 모든 힌트,이를 어떻게 달성 할 수 있습니까?

ver os  XYZ         founder         country     number
1   ms  123.dfer     3.0            us          123
1   ms  123.dfer     2.0            us          123
1   ms  123.dfer     7.0.0          us          123

해결법

  1. ==============================

    1.당신은 테이블 SRC에서 select 절에 get_json_object (골, '$ .Rtype.ver'), get_json_object (골, '$ .Rtype.os')를 사용할 수 있습니다

    당신은 테이블 SRC에서 select 절에 get_json_object (골, '$ .Rtype.ver'), get_json_object (골, '$ .Rtype.os')를 사용할 수 있습니다

  2. from https://stackoverflow.com/questions/43511851/json-issue-in-hive by cc-by-sa and MIT license