如何在类似于mysql的配置单元查询上执行按位或运算。
例如在mysql中,我们按位或按以下方式执行:SELECT user_name, BIT_OR(file_permission) FROM user_permission GROUP BY user_name
最佳答案
有一个Bitwise or operator in hive:
A | B
Operand types: All number types
Gives the result of bitwise OR of A and B. The type of the result is the same as the common parent(in the type hierarchy) of the types of the operands.
但是,从您的代码示例来看,您似乎需要一个汇总的按位或函数(UDAF)。这种聚合功能在 hive 中不容易存在。您将必须实现自定义UDAF。
另一个效率较低但更简单的选项:您可以使用
collect_list
并实现一个简单的UDF,该UDF对数组的所有元素进行按位执行。
关于hadoop - 是否可以在Hive中执行按位分组功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45732276/