Skip to main content
Version: Next

and

Aggregate Function

and logical AND of input values

Synopsis

and(bool) -> bool

Description

The and aggregate function computes the logical AND over all of its input.

Examples

Anded value of simple sequence:

echo 'true false true' | zq -z 'and(this)' -

=>

false

Continuous AND of simple sequence:

echo 'true false true' | zq -z 'yield and(this)' -

=>

true
false
false

Unrecognized types are ignored and not coerced for truthiness:

echo 'true "foo" 0 false true' | zq -z 'yield and(this)' -

=>

true
true
true
false
false

AND of values grouped by key:

echo '{a:true,k:1} {a:true,k:1} {a:true,k:2} {a:false,k:2}' |
zq -z 'and(a) by k | sort' -

=>

{k:1,and:true}
{k:2,and:false}