bit_or aggregate function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns the bitwise OR of all input values in the group.

To aggregate bit positions into a BINARY bitmap use the bitmap_construct_agg() aggregate function.

To aggregate BINARY input values use the bitmap_or_agg()] aggregate function.

Syntax

bit_or(expr) [FILTER ( WHERE cond ) ]

This function can also be invoked as a window function using the OVER clause.

Arguments

  • expr: An expression that evaluates to an integral numeric.

  • cond: An optional boolean expression filtering the rows used for aggregation.

Returns

The result type matches the argument type.

Examples

> SELECT bit_or(col) FROM VALUES (3), (5) AS tab(col);
 7

> SELECT bit_or(col) FILTER(WHERE col < 8) FROM VALUES (3), (5), (8) AS tab(col);
 7