hive中json格式数据解析

1.在hive中创建源表

use default;
create table if not exists testdata(
mongo_data string
);

2.插入json格式数据

insert into testdata(mongo_data) VALUES(‘{“project_type”: [“5”], “project_uncode”: “MjIwMjE2MDEwODQ5MTM3”, “project_name”: “大企业带动中小企业融通发展项目\t\t”, “enterprise_name”: “东方电气集团东方锅炉股份有限公司”, “social_credit_code”: “915103006207291851”, “legal_representative”: “林光平”, “corporate_phone”: “028-87898567”, “unit_nature”: [“2”], “main_contents”: “自2020年12月16日起截至2021年12月31日,东方锅炉及省内子企业通过原材料和零部件采购、生产扩散、日常经营服务外包等采购方式,带动省内中小型企业共83家参与公司发展,累计采购产品/服务总金额57606万元。”, “location”: {“detail”: “五星街黄桷坪路150号”, “region”: [{“code”: “510000”, “name”: “四川省”}, {“code”: “510300”, “name”: “自贡市”}, {“code”: “510302”, “name”: “自流井区”}]}, “industry”: [“02”], “key_areas”: [“99”], “key_areas_02”: [“99”], “key_areas_99”: [“99”], “contacts”: “文砚博”, “contact_information”: “13980962639”, “years”: 2022, “fieldvzpzn23yn”: “项目申报单位概况”, “registered_capital”: null, “company_location”: {“detail”: “”, “region”: [{“code”: “510000”, “name”: “四川省”}, null, null]}, “whether1”: “选项一”, “number_of_employees”: null, “total_assets”: null, “leverage”: null, “shareholder”: [{“num”: null, “shareholding_ratio”: 0}], “production_scale”: [{“sales_revenue”: null, “market_share”: 0, “export_volume”: null}], “fieldaa5xfuxpj”: “申报单位技术创新开发情况”, “num_techician”: null, “proportion”: null, “technical_personnel”: null, “total_r_d_invest_two”: null, “r_d_equip_invest_two”: null, “fieldbok2ymofs”: “项目基本信息”, “projectstate”: [], “end_time”: null, “production_time”: null, “energyuse_year”: null, “field2wmuow93h”: “项目投资(万元)”, “total_investment”: null, “fixed_investment”: null, “device_investment”: null, “raise_independently”: null, “financing”: null, “investment_completed”: null, “fixed_assets”: null, “device_assets”: null, “field0rkzwqdkq”: “融资需求(万元)”, “fieldcgqkrfdgc”: “项目达产后的预期经济效益(万元)”, “expected_sales_reven”: null, “profit”: null, “tax_revenue”: null, “new_employment”: null, “cooperative_unit”: [{“own_funds”: null, “other_funds”: null, “equity_financing”: null, “loans”: null, “total_investment1”: null}], “status”: [“1”], “key_flag”: [“0”], “declare_status”: [], “user_level”: [“1”], “area_qu”: “510302”, “abuts_county”: [“否”], “location_country”: “自流井区”, “location_city”: “自贡市”, “start_end_time”: “2022-02至2022-02”, “coding”: “2022510302000099”}’);

3.验证存储的数据格式是否是json格式

select get_json_object(mongo_data,’. c o m p a n y l o c a t i o n . r e g i o n [ 0 ] . n a m e ′ ) a

Original: https://blog.csdn.net/chenhua_19891230/article/details/125254017
Author: ch数时代_搬砖工程师
Title: hive中json格式数据解析

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/818268/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球