Skip to content

refactor(dynamodb): split evaluate_single_key_condition + find_partiql_where_indices#353

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-dynamodb-expr-evaluators
Apr 13, 2026
Merged

refactor(dynamodb): split evaluate_single_key_condition + find_partiql_where_indices#353
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-dynamodb-expr-evaluators

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

  • `evaluate_single_key_condition` split into `key_cond_begins_with` / `key_cond_between` / `key_cond_simple_comparison`. The dispatch function is now a 12-line guard ladder. The `key_cond_` prefix avoids collision with the existing `eval_begins_with` that backs the FilterExpression evaluator — the two share the function-call grammar but have different return types and operand-type handling, so they intentionally stay separate.
  • `find_partiql_where_indices` split into `split_partiql_and_clauses` (the case-insensitive AND splitter) and `parse_partiql_equality_conditions` (the `col = literal` pair extractor). The outer function is now a 12-line filter loop.

Already-clean targets from the original audit list (judged not worth splitting)

  • `parse_path_segments` (40L): single-pass char state machine; the bracket-index sub-block is short and reading it inline matches the surrounding parser style.
  • `apply_update_expression` (40L): already a clean dispatch over the `UpdateAction` enum that delegates to per-action helpers (`apply_set_assignment`, `apply_add_assignment`, `apply_delete_assignment`).
  • `parse_update_clauses` (35L): focused on keyword-position scan + segment slicing; can't be split without rearranging the algorithm.
  • `assign_list_index`: short, one job (replace-or-append at index, validate type).
  • `evaluate_size_comparison` (45L): two clear sub-tasks already inline (parse `size(path) op :val`, evaluate against the resolved attribute size).

Test plan

  • `cargo fmt`
  • `cargo clippy -p fakecloud-dynamodb --all-targets -- -D warnings`
  • `cargo test -p fakecloud-dynamodb --lib` — 92 passed
  • `cargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance`

Summary by cubic

Refactors DynamoDB expression evaluators by splitting two large functions into small, focused helpers with no behavior changes. This simplifies key-condition and PartiQL WHERE processing and makes them easier to test.

  • Refactors
    • Split evaluate_single_key_condition into key_cond_begins_with, key_cond_between, and key_cond_simple_comparison; dispatch is now a small guard ladder and preserves S-only begins_with and correct operator matching.
    • Split find_partiql_where_indices into split_partiql_and_clauses (case-insensitive AND) and parse_partiql_equality_conditions (col = literal/param); the outer function is now a short filter loop and keeps prior drop-on-parse-fail behavior.

Written for commit 5a55fe1. Summary will update on new commits.

…l_where_indices

evaluate_single_key_condition split into key_cond_begins_with /
key_cond_between / key_cond_simple_comparison so the dispatch function
is a 12-line guard ladder. The 'key_cond_' prefix avoids collision with
the existing eval_begins_with that backs the FilterExpression evaluator
— the two share the function-call grammar but have different return
types and operand-type handling, so they intentionally stay separate.

find_partiql_where_indices split into split_partiql_and_clauses (the
case-insensitive AND splitter) and parse_partiql_equality_conditions
(the col = literal pair extractor). The outer function is now a 12-line
filter loop.

Other DynamoDB targets in the original audit list judged already-clean:
parse_path_segments (single-pass char state machine, 40L), apply_update_expression
(40L dispatch over UpdateAction enum), parse_update_clauses (35L
focused on keyword-position scan), assign_list_index (small),
evaluate_size_comparison (45L, two clear sub-tasks already inline).
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@vieiralucas vieiralucas merged commit c31b14d into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup-dynamodb-expr-evaluators branch April 13, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant