Skip to content

[DISCUSSION] Expression ( Predicate ) Design #126

@mapleFU

Description

@mapleFU

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]:

  1. Create InclusiveProjection
  2. Each Transform has a project method, with project the partition expression to the normal expression, and return a Predicate ( unbounded filter )

Reference

In java and rust, Reference implements use similiar way:

  1. Unbounded has a "name"
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions