[英]Is there a Hiveql function using which we can pull records from a table where a JSON type column has a specific value for a key?
我正在尋找記錄數,其中 json 類型的列(類型)在名為 product_type 的表中具有特定鍵:值。
_______________________________________________________
id | product | type |
1 | product_1 | {"costly": true, "l_type": true} |
2 | product_2 | {"costly": false, "l_type": true} |
3 | product_3 | {"costly": false, "l_type": true} |
4 | product_4 | {"costly": false, "l_type": true} |
_______________________________________________________
就像是-
select count(id) from product_table where type has {"costly": false}
我試過的:
select count(*) from product_table where type LIKE '%"costly": false%'
-> 沒有產生任何結果。
期望得到:3(因為有 3 條記錄在 type 列中的值為 false,鍵成本高。)
我解決了:
select count(*) from product_table where get_json_object(type,$.costly) is true;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.