All Products
Search
Document Center

MaxCompute:BOOL_OR

Last Updated:Mar 25, 2026

An aggregate function that returns true if any value in a Boolean column is true, and false if all values are false.

Syntax

BOOLEAN BOOL_OR(BOOLEAN <expr>)

Parameters

ParameterRequiredTypeDescription
exprYesBOOLEANThe Boolean expression to evaluate across all rows in a group.

Return value

Returns a BOOLEAN value according to these rules:

  • Returns true if at least one value in the group is true.

  • Returns false if all values in the group are false.

  • Ignores NULL values.

Examples

Example 1: Basic usage

SELECT BOOL_OR(colname)
FROM VALUES (true), (false), (false) AS tab(colname);

Result: true — at least one row is true.

Example 2: NULL values are ignored

SELECT BOOL_OR(colname)
FROM VALUES (NULL), (true), (false) AS tab(colname);

Result: true — the NULL row is excluded from evaluation.

SELECT BOOL_OR(colname1)
FROM VALUES (false), (false), (NULL) AS tab(colname1);

Result: false — after excluding the NULL, all remaining values are false.

Example 3: Filter rows before aggregation with FILTER

FILTER(WHERE ...) restricts which rows participate in the aggregation without removing rows from the result set. This differs from WHERE, which filters rows before grouping and can drop entire groups from the output.

SELECT BOOL_OR(colname1) FILTER(WHERE colname2 = 1)
FROM VALUES (true, 1), (false, 1), (true, 2) AS tab(colname1, colname2);

Result: true — only rows where colname2 = 1 are evaluated; the row (true, 2) is excluded from the aggregation.

Related functions

  • BOOL_AND: Returns true only if all values in the group are true. Use this when you need "all rows satisfy a condition" semantics instead of "any row satisfies a condition."