Predicate#
Interface#
-
class Predicate#
Predicate interface.
To create a predicate, please use
PredicateBuilder.See also
Subclassed by paimon::CompoundPredicate, paimon::LeafPredicate
-
class LeafPredicate : public virtual paimon::Predicate#
Leaf node of a
Predicatetree. Compares a field with literals.
-
class CompoundPredicate : public virtual paimon::Predicate#
Non-leaf node in a
Predicatetree.Its evaluation result depends on the results of its children.
-
class Function#
Functionrepresents a predicate function used in query expressions and filtering operations.It serves as the base class for all predicate functions in Paimon.
Public Types
-
template<typename T>
class FunctionVisitor# A visitor interface for evaluating filter predicates on indexed columns.
- Template Parameters:
T – The result type produced by each visit method (e.g., a file index result or global index result).
Public Functions
-
virtual ~FunctionVisitor() = default#
-
virtual Result<T> VisitEqual(const Literal &literal) = 0#
Evaluates the equality (==) predicate against the given literal.
-
virtual Result<T> VisitNotEqual(const Literal &literal) = 0#
Evaluates the inequality (!=) predicate against the given literal.
-
virtual Result<T> VisitLessThan(const Literal &literal) = 0#
Evaluates the less-than (<) predicate against the given literal.
-
virtual Result<T> VisitLessOrEqual(const Literal &literal) = 0#
Evaluates the less-than-or-equal (<=) predicate against the given literal.
-
virtual Result<T> VisitGreaterThan(const Literal &literal) = 0#
Evaluates the greater-than (>) predicate against the given literal.
-
virtual Result<T> VisitGreaterOrEqual(const Literal &literal) = 0#
Evaluates the greater-than-or-equal (>=) predicate against the given literal.
-
virtual Result<T> VisitIn(const std::vector<Literal> &literals) = 0#
Evaluates the IN predicate against a list of literals.
-
virtual Result<T> VisitNotIn(const std::vector<Literal> &literals) = 0#
Evaluates the NOT IN predicate against a list of literals.
-
virtual Result<T> VisitStartsWith(const Literal &prefix) = 0#
Evaluates whether string values start with the given prefix.
-
class Literal#
Literal represents a constant value used in predicate expressions.
Literal support BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, FLOAT, DOUBLE, STRING, BINARY, TIMESTAMP, DECIMAL, DATE.
Public Functions
-
explicit Literal(FieldType type)#
Creates a null literal of the specified type.
- Parameters:
type – The field type for this null literal.
-
template<typename T>
explicit Literal(const T &val)# Creates a literal from a typed value.
The template parameter T must be compatible with one of the supported field types.
- Template Parameters:
T – The C++ type of the value (must match a supported FieldType).
- Parameters:
val – The value to store in the literal.
-
Literal(FieldType binary_type, const char *str, size_t size)#
Creates a literal from binary data (string or binary type).
The data is copied into the literal’s internal storage.
Note
BLOBtype is not supported by literal- Parameters:
binary_type – Must be either
STRINGorBINARYfield type.str – Pointer to the binary data.
size – Size of the binary data in bytes.
-
Literal(FieldType binary_type, const char *str, size_t size, bool own_data)#
Creates a literal from binary data with optional data ownership.
- Parameters:
binary_type – Must be either
STRINGorBINARYfield type.str – Pointer to the binary data.
size – Size of the binary data in bytes.
own_data – If true, the literal takes ownership and will free the data; if false, the caller must ensure the data remains valid.
-
Literal(FieldType date_type, int32_t date_value)#
Creates a date literal from an integer value.
- Parameters:
date_type – Must be
DATEfield type.date_value – Date value as days since epoch (1970-01-01).
-
~Literal()#
-
bool IsNull() const#
Checks if this literal represents a null value.
-
template<typename T>
T GetValue() const# Gets the typed value stored in this literal.
Warning
This method is unsafe - caller must verify the type and null status first.
- Template Parameters:
T – The expected C++ type of the value.
- Returns:
The value of type
T.
-
std::string ToString() const#
-
size_t HashCode() const#
Gets the hash code for this literal.
-
Result<int32_t> CompareTo(const Literal &other) const#
Compares this literal with another literal.
The comparison follows SQL semantics for the respective data types.
- Parameters:
other – The literal to compare with.
- Returns:
Result containing -1 (this < other), 0 (this == other), or 1 (this > other), or an error if the literals are not comparable.
-
explicit Literal(FieldType type)#
-
class PredicateBuilder#
A utility class to create
Predicateobject for common filter conditions.PredicateBuilder provides static factory methods to create various types of predicates that can be used for filtering data in Paimon tables.
Public Static Functions
-
static std::shared_ptr<Predicate> Equal(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &literal)#
Create an equality predicate (field == literal).
- Parameters:
field_index – The index of the field in read schema (0-based).
field_name – The name of the field.
field_type – The data type of the field.
literal – The literal value to compare against.
- Returns:
A shared pointer to the created Predicate object.
-
static std::shared_ptr<Predicate> NotEqual(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &literal)#
Create a not-equal predicate (field != literal).
-
static std::shared_ptr<Predicate> LessThan(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &literal)#
Create a less-than predicate (field < literal).
-
static std::shared_ptr<Predicate> LessOrEqual(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &literal)#
Create a less-than-or-equal predicate (field <= literal).
-
static std::shared_ptr<Predicate> GreaterThan(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &literal)#
Create a greater-than predicate (field > literal).
-
static std::shared_ptr<Predicate> GreaterOrEqual(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &literal)#
Create a greater-than-or-equal predicate (field >= literal).
-
static std::shared_ptr<Predicate> IsNull(int32_t field_index, const std::string &field_name, const FieldType &field_type)#
Create an IS NULL predicate (field IS NULL).
-
static std::shared_ptr<Predicate> IsNotNull(int32_t field_index, const std::string &field_name, const FieldType &field_type)#
Create an IS NOT NULL predicate (field IS NOT NULL).
-
static std::shared_ptr<Predicate> In(int32_t field_index, const std::string &field_name, const FieldType &field_type, const std::vector<Literal> &literals)#
Create an IN predicate (field IN (literal1, literal2, …)).
Tests whether the field value matches any of the provided literal values.
-
static std::shared_ptr<Predicate> NotIn(int32_t field_index, const std::string &field_name, const FieldType &field_type, const std::vector<Literal> &literals)#
Create a NOT IN predicate (field NOT IN (literal1, literal2, …)).
Tests whether the field value does not match any of the provided literal values.
-
static std::shared_ptr<Predicate> Between(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &included_lower_bound, const Literal &included_upper_bound)#
Create a BETWEEN predicate (field BETWEEN lower_bound AND upper_bound).
Tests whether the field value falls within the specified range (inclusive on both ends).
- Parameters:
field_index – The index of the field in read schema (0-based).
field_name – The name of the field.
field_type – The data type of the field.
included_lower_bound – The lower bound of the range (inclusive).
included_upper_bound – The upper bound of the range (inclusive).
Create an AND predicate combining multiple predicates.
Creates a logical AND operation that evaluates to true only when all input predicates evaluate to true.
- Parameters:
predicates – A vector of shared pointers to the predicates, which must not be empty.
Create an OR predicate combining multiple predicates.
Creates a logical OR operation that evaluates to true when at least one of the input predicates evaluates to true.
- Parameters:
predicates – A vector of shared pointers to the predicates, which must not be empty.
-
static std::shared_ptr<Predicate> Equal(int32_t field_index, const std::string &field_name, const FieldType &field_type, const Literal &literal)#