Skip to content

Feature/pattern resolver#72

Merged
genezhang merged 1 commit intomainfrom
feature/pattern-resolver
Feb 11, 2026
Merged

Feature/pattern resolver#72
genezhang merged 1 commit intomainfrom
feature/pattern-resolver

Conversation

@genezhang
Copy link
Copy Markdown
Owner

This pull request introduces the new PatternResolver system for automatic type enumeration in untyped graph patterns, significantly enhancing schema intelligence and exploratory query capabilities in the query planner. The PatternResolver systematically discovers untyped variables, queries the schema for valid types, generates all valid combinations (with configurable limits), validates relationships, clones queries per combination, and combines them via UNION ALL. The integration is robust, with full unit test coverage and minimal performance overhead. Supporting changes include new configuration, status message infrastructure, and updates to documentation and test counts.

Major features and changes:

Schema Intelligence & Query Planning:

  • Added the PatternResolver module with full integration into the analyzer pipeline (src/query_planner/analyzer/pattern_resolver.rs, src/query_planner/analyzer/mod.rs). This system enables automatic type enumeration for untyped graph variables, generating all valid type combinations and combining them via UNION ALL, with graceful fallback and schema constraint validation. [1] [2] [3]
  • Introduced configuration for limiting type combinations via the new pattern_resolver_config module and the CLICKGRAPH_MAX_TYPE_COMBINATIONS environment variable, with a default of 38.

Infrastructure & Status Reporting:

  • Extended PlanCtx to include a status message system for reporting info, warnings, and errors during planning—used by PatternResolver to communicate combination limits, missing types, etc. Added methods for adding, retrieving, and clearing messages. [1] [2] [3] [4] [5] [6] [7]

Documentation & Test Updates:

  • Updated CHANGELOG.md and STATUS.md to document the PatternResolver feature, architecture, configuration, integration, and testing. Increased the reported number of passing unit and integration tests. [1] [2]

Codebase Cleanups & Minor Refactoring:

These changes collectively enable true exploratory graph queries without manual type annotations, improve planning transparency, and maintain robust performance and test coverage.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a new PatternResolver analyzer pass intended to systematically resolve remaining untyped graph variables by enumerating schema-valid type combinations and producing a UNION ALL across typed query clones, along with supporting planning-status reporting and configuration.

Changes:

  • Added PatternResolver (+ config) and integrated it into the analyzer pipeline after TypeInference.
  • Extended PlanCtx with a status message collection mechanism for analyzer passes to report info/warnings/errors.
  • Updated docs/status/changelog and performed small cleanup refactors (mostly unused imports).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/query_planner/analyzer/pattern_resolver.rs New analyzer pass implementing discovery, combination generation, validation, cloning, and UNION ALL composition.
src/query_planner/analyzer/pattern_resolver_config.rs Adds env-configured max-combinations with caching.
src/query_planner/analyzer/mod.rs Wires PatternResolver into the analyzer pipeline (Step 2.1).
src/query_planner/plan_ctx/mod.rs Adds StatusLevel + message storage and methods on PlanCtx.
src/query_planner/plan_ctx/builder.rs Initializes status_messages in PlanCtxBuilder.
notes/pattern-resolver.md / STATUS.md / CHANGELOG.md Documentation updates describing the feature and updated test counts/status.
Misc files (Bolt/procedures/parser/render/generator) Minor import cleanups / small refactors.

Comment thread src/query_planner/analyzer/pattern_resolver.rs Outdated
Comment thread src/query_planner/analyzer/pattern_resolver.rs Outdated
Comment thread src/query_planner/analyzer/pattern_resolver_config.rs
Comment thread src/query_planner/plan_ctx/mod.rs
Comment thread src/query_planner/analyzer/pattern_resolver.rs
Comment thread src/query_planner/analyzer/pattern_resolver.rs Outdated
@genezhang genezhang force-pushed the feature/pattern-resolver branch 2 times, most recently from 9cbebb9 to 381dded Compare February 11, 2026 17:59
@genezhang genezhang requested a review from Copilot February 11, 2026 18:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 88 out of 88 changed files in this pull request and generated 7 comments.

Comment thread src/clickhouse_query_generator/to_sql_query.rs Outdated
Comment thread src/server/bolt_protocol/result_transformer.rs
Comment thread src/query_planner/analyzer/mod.rs
Comment thread src/render_plan/from_builder.rs
Comment thread src/server/bolt_protocol/result_transformer.rs
Comment thread src/query_planner/plan_ctx/table_ctx.rs
Comment thread src/clickhouse_query_generator/to_sql_query.rs Outdated
@genezhang genezhang force-pushed the feature/pattern-resolver branch from 381dded to 4b877ef Compare February 11, 2026 19:54
…xpand

- New analyzer pass that automatically resolves unlabeled Cypher patterns
  into all valid schema-backed label combinations
- Generates UNION ALL query plans for multi-type patterns
- Schema-aware validation filters impossible label combinations
- Configurable via PatternResolverConfig (enabled by default)
- Handles complex patterns: undirected edges, multi-hop paths, WHERE clauses

- Three-mode property selection: IdOnly, Individual, WholeNode
- Multi-type VLP expansion with UNION ALL CTE generation
- VLP + WITH CTE integration for chained WITH-MATCH queries
- Undirected VLP patterns generate correct per-direction CTEs
- VLP CTE schema population for pattern comprehensions
- start_type/end_type columns in VLP path tuples

- Bolt Path serialization from VLP CTE tuple data (transform_vlp_path)
- Browser expand queries return proper Path objects with nodes AND edges
- Fixed UNION split pipeline for multi-var id() queries
- Fixed label resolution from encoded deterministic IDs
- Removed semantic-violating query rewrites (path-to-node, undirected)
- Relationship-fetch queries preserve original directed semantics

- CTE+JOIN pattern comprehension for size([(a)--() | 1])
- RETURN-context pattern comprehension CTE generation
- Single-column UNION ALL pattern comp CTE structure

- New optimizer pass prunes impossible UNION branches
- Label-aware pruning based on WHERE clause constraints
- Bidirectional pruning for relationship patterns

- id() function splitting for multi-var IN clauses
- Bidirectional pruning and single-label injection
- String arena for efficient AST string management

- Task-local QueryContext for CTE name registry (thread safety)
- CTE column reference uses cte_manager property mappings
- Computed WITH aliases typed as scalar instead of path/node
- Multi-type VLP CTE naming in from_builder
- Duplicate relationship type deduplication

96 files changed, +10364/-1102 lines
All 1006 unit tests pass (995 + 11 ignored)
@genezhang genezhang force-pushed the feature/pattern-resolver branch from 4b877ef to 9830688 Compare February 11, 2026 20:46
@genezhang genezhang merged commit 46f3178 into main Feb 11, 2026
2 checks passed
@genezhang genezhang deleted the feature/pattern-resolver branch February 11, 2026 20:49
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