Skip to main content
The Expressions class provides factory methods for creating filter expressions and predicates in Apache Iceberg.

Overview

Expressions are used to:
  • Filter data during scans
  • Define partition predicates
  • Specify row-level conditions
  • Create aggregations
All expressions are immutable and can be safely reused.

Logical Operators

and()

Combines two expressions with AND logic.
Example:

or()

Combines two expressions with OR logic.
Example:

not()

Negates an expression.
Example:

Comparison Predicates

equal()

Tests for equality.
Example:

notEqual()

Tests for inequality.
Example:

lessThan()

Tests if value is less than the given value.
Example:

lessThanOrEqual()

Tests if value is less than or equal to the given value.

greaterThan()

Tests if value is greater than the given value.
Example:

greaterThanOrEqual()

Tests if value is greater than or equal to the given value.

String Predicates

startsWith()

Tests if string starts with a prefix.
Example:

notStartsWith()

Tests if string does not start with a prefix.
Example:

Null Predicates

isNull()

Tests if value is null.
Example:

notNull()

Tests if value is not null.
Example:

isNaN()

Tests if value is NaN (for floating point types).

notNaN()

Tests if value is not NaN.

Set Predicates

in()

Tests if value is in a set of values.
Example:

notIn()

Tests if value is not in a set of values.
Example:

Transform Functions

bucket()

Bucket transform.
Example:

year()

Year transform for dates and timestamps.
Example:

month()

Month transform for dates and timestamps.
Example:

day()

Day transform for dates and timestamps.
Example:

hour()

Hour transform for timestamps.
Example:

truncate()

Truncate transform.
Example:

Literals

lit()

Creates a literal from a value.
Example:

Timestamp Literals

Example:

Aggregates

count()

Count non-null values.

countNull()

Count null values.

countStar()

Count all rows.

max()

Maximum value.

min()

Minimum value.

Always True/False

alwaysTrue()

Expression that always evaluates to true.

alwaysFalse()

Expression that always evaluates to false.

Examples

Basic Filtering

Complex Filters

Date and Time Filtering

String Filtering

Partition Filtering

Null Handling

Dynamic Filter Building

Combining Transforms

See Also