如何从presto中的查询中获取数字?

jm81lzqq  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(825)

例如,查询的值为:

currentView=/review_list_renewal_page&page=SDP&vendorItemID=3081429363&categoryID=&itemID=52159373&eventReferrer=/click_top_button&itemProductID=&pdpStyle=BRAND_SDP_FASHION&content=option_picker&type=brandSDPFashion&q=&logCategory=event&logType=click&productID=12257000&optionStatus=normal&searchId=&memberID=6339421&rank=&request_time=1487114662328&tz=+0900&appVersion=4.5.2&wl_mo=LG-F460S&wl_ma=LGE&wl_sn=Android&wl_v=5.0.1&wl_r=1440x2392&wl_l=ko&wl_c=KR

我使用str \u to \u map(query,“&”,“=”[“productid”]获取Map到配置单元中productid的编号。但现在在presto中,函数似乎无效。那么如何从查询中检索它呢?我认为这个查询的格式不严格。

9jyewag0

9jyewag01#

split_to_map(query,'&','=')['productId']

https://prestodb.io/docs/current/functions/string.htmlhttpshttp://prestodb.io/docs/current/functions/map.html
演示

presto> select split_to_map('currentView=/review_list_renewal_page&page=SDP&vendorItemID=3081429363&categoryID=&itemID=52159373&eventReferrer=/click_top_button&itemProductID=&pdpStyle=BRAND_SDP_FASHION&content=option_picker&type=brandSDPFashion&q=&logCategory=event&logType=click&productID=12257000&optionStatus=normal&searchId=&memberID=6339421&rank=&request_time=1487114662328&tz=+0900&appVersion=4.5.2&wl_mo=LG-F460S&wl_ma=LGE&wl_sn=Android&wl_v=5.0.1&wl_r=1440x2392&wl_l=ko&wl_c=KR^J','&','=')['productID'];
  _col0
----------
 12257000

相关问题