Skip to content

bug(engine): index_match panics on ExprProject lhs when planning a scan path #858

Description

@carllerche

Summary

When the planner walks a filter expression to decide whether an index applies, match_restriction (crates/toasty/src/engine/index/index_match.rs:49) hits todo!() on a BinaryOp { lhs: ExprProject { .. }, op: =, rhs: String(..) }. This is the shape produced by lifting a belongs-to filter onto an embedded-field equality. Surfaces on the DynamoDB scan path; should likely be handled (or rejected with an error) instead of panicking.

Reproducer

crates/toasty-driver-integration-suite/src/tests/lift_belongs_to_complex_filter.rs:14 (lift_belongs_to_preserves_embedded_field_filter). Switch requires(sql) to requires(scan). Runs on DynamoDB and panics.

Additional context

panicked at crates/toasty/src/engine/index/index_match.rs:49:22:
not yet implemented: expr=ExprBinaryOp {
    lhs: ExprProject {
        base: [Column(ExprColumn { nesting: 0, table: 0, column: 1 })],
        projection: Projection(0),
    },
    op: =,
    rhs: String("Seattle"),
}

Backtrace:

2: match_restriction
     at crates/toasty/src/engine/index/index_match.rs:49:22
3: build_index_matches
     at crates/toasty/src/engine/index.rs:179:29
4: plan_index_path

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-enginetoasty/src/engine/ — simplify, lower, plan, execC-bugA defect: the code behaves incorrectly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions