2017-02-16 9 views
1

は、クエリの値を有する:prestoでクエリから数値を取得する方法は?例えば

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 

Iはハイブに商品コードにマッピングされた番号を取得するSTR_TO_MAP(クエリ、 "&"、 "=")[ "商品コード" を]使用しました。しかし、現在では、機能は無効と思われます。だからどのようにクエリから取得するには? 質問は厳密な形式ではありません。

答えて

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

https://prestodb.io/docs/current/functions/string.html https://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 
+0

感謝。私はちょうど来た質問を解決するためにあなたを助けてもらえますか? – yanachen