Skip to content

Conversation

@xav-db
Copy link
Member

@xav-db xav-db commented Nov 24, 2025

Greptile Overview

Greptile Summary

Optimized HQL compiler to handle inner traversals in WHERE clause comparisons. Previously, comparing properties from different variables (e.g., _::{login}::EQ(toUser::{login})) would generate inefficient code with unnecessary G::from_iter calls. The fix introduces PropertyEq and PropertyNeq operators that detect simple property access patterns and generate direct get_property() calls instead.

Key Changes:

  • Added is_simple_property_traversal() helper that identifies property-only traversals (no graph navigation)
  • Created PropertyEq and PropertyNeq boolean operators for optimized property comparisons
  • Updated Equal/NotEqual handling in traversal_validation.rs to use optimized path for simple cases
  • Added comprehensive test coverage with GitHub graph and document embedding schemas

Impact:

  • Enables queries like CheckFollowsEdge that filter edges by comparing properties across variables
  • Generates more efficient Rust code for common property comparison patterns
  • Maintains backward compatibility by falling back to full traversal parsing for complex cases

Important Files Changed

File Analysis

Filename Score Overview
helix-db/src/helixc/analyzer/methods/traversal_validation.rs 5/5 Added is_simple_property_traversal helper function and optimized Equal/NotEqual operators to use PropertyEq/PropertyNeq for simple property access, avoiding unnecessary G::from_iter calls
helix-db/src/helixc/generator/bool_ops.rs 5/5 Added PropertyEq and PropertyNeq boolean operators that generate optimized property comparison code using get_property instead of creating full traversals
helix-db/src/helixc/generator/traversal_steps.rs 5/5 Updated WhereRef Display implementation to handle new PropertyEq/PropertyNeq boolean operators with unreachable guard for reserved properties
hql-tests/tests/user_test_2/queries.hx 5/5 New GitHub-style graph queries including CheckFollowsEdge query that uses inner traversal comparison pattern _::{login}::EQ(toUser::{login})

Sequence Diagram

sequenceDiagram
    participant User as HQL Query
    participant Analyzer as traversal_validation.rs
    participant BoolOps as bool_ops.rs
    participant Generator as traversal_steps.rs
    participant Output as Generated Rust Code

    User->>Analyzer: WHERE(_::{login}::EQ(toUser::{login}))
    Analyzer->>Analyzer: Validate BooleanOpType::Equal
    Analyzer->>Analyzer: Check if RHS is ExpressionType::Traversal
    Analyzer->>Analyzer: Call is_simple_property_traversal()
    
    alt Simple property traversal
        Analyzer->>Analyzer: Detected: toUser::{login}
        Analyzer->>BoolOps: Create PropertyEq(var: "toUser", property: "login")
        BoolOps->>Generator: Pass PropertyEq to WhereRef
        Generator->>Output: Generate: toUser.get_property("login").map_or(false, |w| w == v)
    else Complex traversal
        Analyzer->>Analyzer: Parse full traversal with validate_traversal()
        Analyzer->>BoolOps: Create Eq with GeneratedValue::Traversal
        BoolOps->>Generator: Pass Eq with traversal
        Generator->>Output: Generate: G::from_iter(...) comparison
    end
Loading

@xav-db
Copy link
Member Author

xav-db commented Nov 24, 2025

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

10 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@xav-db xav-db marked this pull request as ready for review November 24, 2025 01:09
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

10 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@xav-db xav-db merged commit 2338520 into dev Nov 26, 2025
20 checks passed
@xav-db xav-db deleted the fixing-issue-with-inner-traversals branch November 26, 2025 18:47
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.

2 participants