[英]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.