HIVE數據查詢

數據: 

request_id app_key method_name api_name request_time request_param union_id
0b115ef6_jyvs8p54_39039180 unknowledge com.jd.union.open.gateway.service.api.goods.GoodsServiceImpl.queryJFGoods jd.union.open.goods.jingfen.query 2019-08-04 01:00:03:789 {"eliteId":1,"pageIndex":4,"pageSize":50,"sort":"desc","sortName":"commissionShare"} 1102261988

數據查詢 

1、instr

select * from union_open_gateway_xxx where api_name in ('jd.union.open.promotion.common.get','jd.union.open.promotion.byunionid.get','	
jd.union.open.promotion.bysubunionid.get') and dt='2019-07-28' and instr(request_param,'ad_od')>0 order by union_id;

2、get_json_object(get_json_object(string json_column, string attri))

select * from union_open_gateway_xxx where dt='2019-08-04' and api_name='jd.union.open.goods.jingfen.query' and get_json_object(request_param,'$.eliteId')=22
select get_json_object(request_param,'$.eliteId'),get_json_object(request_param,'$.pageIndex') total from union_open_gateway_xxx where api_name='jd.union.open.goods.jingfen.query' and dt='2019-08-05' limit 10;

select request_id from union_open_gateway_comm_log where dt='2020-01-07' 
and api_name='jd.union.open.position.create' 
and get_json_object(request_param,'$.siteId') is null) 

多層

select  get_json_object(data, '$.user.city.name') from test;

數組值[]

select  get_json_object(data, '$.store.fruit[0]') from test;

3、json_tuple(元組數據獲取)

select json_tuple(request_param,'eliteId','pageIndex','pageSize') from union_open_gateway_xxx where api_name='jd.union.open.goods.jingfen.query' and dt='2019-08-05' limit 10;

4、if()

select if(tareget_col is null, 0, cslt.self_amount) as new_column from table_name;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章