-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Iceberg [1] and iceberg-rust [2] both have expression system. There are some design trade-off:
Bind
Both iceberg and iceberg-rust have concept of "bind". I guess this concept is from database query compiler. Specifically, it means bind the reference ( we name it as "term" later ) from "name" to a iceberg Schema
with case_sensitive
setting.
In the iceberg java and iceberg-rust's code, the expression itself doesn't need to Bind from expr naming to a specific structure.
Term
In Java's implementation, Term
has the derivation below:
interface Term;
interface Unbound {
Bounded Bind(Schema, caseSensitive);
NamedReference<?> ref();
}
class UnboundTerm : Term, Unbound;
class BoundedTerm : Term;
class NamedReference : UnboundTerm;
class UnbounedTransform : UnboundTerm;
class UnbounedExtract : UnboundTerm;
class BoundReference : BoundTerm;
class BounedTransform : BoundTerm;
class BounedExtract : BoundTerm;
The rust also has bind and Transform, but it uses different way to handle this:
type Term = UnboundedTerm;
Instead, it uses InclusiveProjection
to convert the PartitionSpec
to a expression, rules may like [3][4]:
- Create
InclusiveProjection
- Each
Transform
has aproject
method, with project the partition expression to the normal expression, and return aPredicate
( unbounded filter )
Reference
In java and rust, Reference
implements use similiar way:
Unbounded
has a "name"Bounded
is has(name, accessor, ..)
The accessor of Schema
is like "index of vector".
Expression
Expression itself doesn't have any bind logic, it just bind all subfields
Evaluator
TBD
[1] https://github.com/apache/iceberg/tree/e5541de0fd1e850f188ff89cac1417b3ae3500a4/api/src/main/java/org/apache/iceberg/expressions
[2] https://github.com/apache/iceberg-rust/tree/f1e79c0d9c76e90cb4ceb1f2c409ef8d1b68b273/crates/iceberg/src/expr
[3] https://github.com/apache/iceberg-rust/blob/f1e79c0d9c76e90cb4ceb1f2c409ef8d1b68b273/crates/iceberg/src/expr/visitors/inclusive_projection.rs#L85
[4] https://github.com/apache/iceberg-rust/blob/f1e79c0d9c76e90cb4ceb1f2c409ef8d1b68b273/crates/iceberg/src/spec/transform.rs#L471