25#include <unordered_set>
45 const std::shared_ptr<T>&
term()
const {
return term_; }
55 std::shared_ptr<T> term_;
68 std::shared_ptr<const NamedReference>
reference()
const override = 0;
72 bool case_sensitive)
const override = 0;
77 bool is_unbound_predicate()
const override {
return true; }
83 virtual std::span<const Literal>
literals()
const = 0;
124 std::vector<Literal> values);
128 std::shared_ptr<const NamedReference>
reference()
const override {
129 return BASE::term()->reference();
137 bool case_sensitive)
const override;
143 std::span<const Literal>
literals()
const override {
return values_; }
150 std::vector<Literal> values);
153 std::shared_ptr<B> bound_term)
const;
155 std::shared_ptr<B> bound_term)
const;
157 std::shared_ptr<B> bound_term)
const;
160 std::vector<Literal> values_;
172 std::shared_ptr<BoundReference>
reference()
override {
return term_->reference(); }
176 bool is_bound_predicate()
const override {
return true; }
184 enum class Kind : int8_t {
215 Kind
kind()
const override {
return Kind::kUnary; }
246 Kind
kind()
const override {
return Kind::kLiteral; }
264 using LiteralSet = std::unordered_set<Literal, LiteralHash>;
274 std::span<const Literal> literals);
283 std::shared_ptr<BoundTerm> term,
284 LiteralSet value_set);
293 Kind
kind()
const override {
return Kind::kSet; }
303 std::span<const Literal> literals);
306 LiteralSet value_set);
308 LiteralSet value_set_;
Bound literal predicate (comparison against a single value).
Definition predicate.h:228
static Result< std::unique_ptr< BoundLiteralPredicate > > Make(Expression::Operation op, std::shared_ptr< BoundTerm > term, Literal literal)
Create a bound literal predicate.
Kind kind() const override
Returns the kind of this bound predicate.
Definition predicate.h:246
const Literal & literal() const
Returns the literal being compared against.
Definition predicate.h:242
Result< bool > Test(const Literal &value) const override
Test a value against this predicate.
Result< std::shared_ptr< Expression > > Negate() const override
Returns the negation of this expression, equivalent to not(this).
bool Equals(const Expression &other) const override
Returns whether this expression will accept the same values as another.
std::string ToString() const override
Get a user-readable string representation.
Bound predicates contain bound terms and can be evaluated.
Definition predicate.h:164
virtual Kind kind() const =0
Returns the kind of this bound predicate.
virtual Result< bool > Test(const Literal &value) const =0
Test a value against this predicate.
std::shared_ptr< BoundReference > reference() override
Returns the underlying bound reference for this term.
Definition predicate.h:172
Result< Literal > Evaluate(const StructLike &data) const override
Evaluate this expression against a row-based data.
Bound set predicate (membership testing against a set of values).
Definition predicate.h:262
std::string ToString() const override
Get a user-readable string representation.
bool Equals(const Expression &other) const override
Returns whether this expression will accept the same values as another.
Kind kind() const override
Returns the kind of this bound predicate.
Definition predicate.h:293
static Result< std::unique_ptr< BoundSetPredicate > > Make(Expression::Operation op, std::shared_ptr< BoundTerm > term, std::span< const Literal > literals)
Create a bound set predicate.
const LiteralSet & literal_set() const
Returns the set of literals to test against.
Definition predicate.h:289
Result< std::shared_ptr< Expression > > Negate() const override
Returns the negation of this expression, equivalent to not(this).
static Result< std::unique_ptr< BoundSetPredicate > > Make(Expression::Operation op, std::shared_ptr< BoundTerm > term, LiteralSet value_set)
Create a bound set predicate using a set of literals.
Result< bool > Test(const Literal &value) const override
Test a value against this predicate.
Base class for bound terms.
Definition term.h:64
Bound unary predicate (null, not-null, etc.).
Definition predicate.h:201
std::string ToString() const override
Get a user-readable string representation.
Result< bool > Test(const Literal &value) const override
Test a value against this predicate.
bool Equals(const Expression &other) const override
Returns whether this expression will accept the same values as another.
Kind kind() const override
Returns the kind of this bound predicate.
Definition predicate.h:215
static Result< std::unique_ptr< BoundUnaryPredicate > > Make(Expression::Operation op, std::shared_ptr< BoundTerm > term)
Create a bound unary predicate.
Result< std::shared_ptr< Expression > > Negate() const override
Returns the negation of this expression, equivalent to not(this).
Interface for bound expressions that can be evaluated.
Definition expression.h:360
Represents a boolean expression tree.
Definition expression.h:37
Operation
Operation types for expressions.
Definition expression.h:40
Literal is a literal value that is associated with a primitive type.
Definition literal.h:42
A predicate is a boolean expression that tests a term against some criteria.
Definition predicate.h:38
Expression::Operation op() const override
Returns the operation for an expression node.
Definition predicate.h:42
const std::shared_ptr< T > & term() const
Returns the term this predicate tests.
Definition predicate.h:45
Predicate(Expression::Operation op, std::shared_ptr< T > term)
Create a predicate with an operation and term.
A schema for a Table.
Definition schema.h:51
An immutable struct-like wrapper.
Definition struct_like.h:62
A term is an expression node that produces a typed value when evaluated.
Definition term.h:38
Unbound predicates contain unbound terms and must be bound to a concrete schema before they can be ev...
Definition predicate.h:95
static Result< std::unique_ptr< UnboundPredicateImpl< B > > > Make(Expression::Operation op, std::shared_ptr< UnboundTerm< B > > term)
Create an unbound predicate (unary operation).
Result< std::shared_ptr< Expression > > Bind(const Schema &schema, bool case_sensitive) const override
Bind this UnboundPredicate.
const Term & unbound_term() const override
Returns the term of this predicate as a base Term reference.
Definition predicate.h:141
std::string ToString() const override
Get a user-readable string representation.
static Result< std::unique_ptr< UnboundPredicateImpl< B > > > Make(Expression::Operation op, std::shared_ptr< UnboundTerm< B > > term, std::vector< Literal > values)
Create an unbound predicate with multiple values.
std::shared_ptr< const NamedReference > reference() const override
Returns the reference of this UnboundPredicate.
Definition predicate.h:128
Result< std::shared_ptr< Expression > > Negate() const override
Negate this UnboundPredicate.
std::span< const Literal > literals() const override
Returns the literals of this predicate.
Definition predicate.h:143
static Result< std::unique_ptr< UnboundPredicateImpl< B > > > Make(Expression::Operation op, std::shared_ptr< UnboundTerm< B > > term, Literal value)
Create an unbound predicate with a single value.
bool Equals(const Expression &other) const override
Returns whether this expression will accept the same values as another.
Non-template base class for all UnboundPredicate instances.
Definition predicate.h:63
Result< std::shared_ptr< Expression > > Bind(const Schema &schema, bool case_sensitive) const override=0
Bind this UnboundPredicate.
Result< std::shared_ptr< Expression > > Negate() const override=0
Negate this UnboundPredicate.
std::shared_ptr< const NamedReference > reference() const override=0
Returns the reference of this UnboundPredicate.
virtual std::span< const Literal > literals() const =0
Returns the literals of this predicate.
virtual const Term & unbound_term() const =0
Returns the term of this predicate as a base Term reference.
Base class for unbound terms.
Definition term.h:56
Interface for unbound expressions that need schema binding.
Definition expression.h:339
Define symbol visibility macros for core Iceberg APIs.
Define typed literal values used by expressions.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::expected< T, E > Result
Result alias.
Definition result.h:88