Skip to content

Conversation

@XL-Zhao-23
Copy link

@XL-Zhao-23 XL-Zhao-23 commented Jan 16, 2026

Title

feat(query): implement CREATE/DROP GRAPH DDL statements

Type

  • feat: (new feature)

Scope

  • query: (query engine)
    • parser: (frontend parser)
    • planner: (frontend planner)
    • optimizer: (query optimizer)
    • executor: (execution engine)
  • storage: (storage engine)
    • mvcc: (multi version concurrency control)
    • schema: (graph model and topology)
  • tool: (tools)
    • cli: (cli)
    • sdk: (sdk)
  • none: (N/A)

Description

Issue: #124

This PR implements basic DDL support for GQL (Graph Query Language), specifically the CREATE GRAPH and DROP GRAPH statements. This enables users to dynamically define graph schemas with vertex types, edge types, and their properties.

Example Usage:

CREATE GRAPH mygraph {
  (Person :Person {lastname STRING, firstname STRING, joined DATE}),
  (City :City {name STRING, state STRING, country STRING}),
  (Person)-[:LIVES_IN]->(City)
};

DROP GRAPH mygraph;
  • I have prepared the pull request title according to the requirements.
  • I have successfully run all unit tests and integration tests.
  • I have already rebased the latest master branch.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.

@CLAassistant
Copy link

CLAassistant commented Jan 16, 2026

CLA assistant check
All committers have signed the CLA.

@XL-Zhao-23 XL-Zhao-23 force-pushed the feature/issue-124-basic-ddl branch 2 times, most recently from 4a91545 to f8a2883 Compare January 16, 2026 12:33
XL-Zhao-23 and others added 5 commits January 16, 2026 20:48
Implement bound types using project-standard LabelSet and NodeTypeRef:
- BoundVertexType: vertex type with key, labels (LabelSet), and properties
- BoundEdgeType: edge type with direction, labels, and node references
- NodeTypeRef: enum for Alias/Filler/Empty node type references
- NodeOrEdgeTypeFiller: inline type definition support

Add binder to convert AST to bound types:
- bind_graph_element_type(): entry point for binding
- bind_node_type() and bind_edge_type(): specific binding logic
- string_to_label_id(): hash-based LabelId generation
- bind_node_type_ref(): handle node type reference binding
- Support for all value types (numeric, string, temporal, vector)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add plan nodes for DDL catalog operations:
- CreateGraph: plan node with graph name, type, and CreateKind
- DropGraph: plan node with graph name and if_exists flag
- CreateKind enum: Create/CreateIfNotExists/CreateOrReplace
- BoundGraphType: Nested variant for graph type definitions

Update PlanNode enum with PhysicalCreateGraph and PhysicalDropGraph variants.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add logical planning for CREATE/DROP GRAPH statements:
- bind_create_graph(): bind CREATE GRAPH with graph type
- bind_drop_graph(): bind DROP GRAPH with if_exists flag
- plan_create_graph(): create CreateGraph plan node
- plan_drop_graph(): create DropGraph plan node

Integrate with existing binder and planner infrastructure.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add optimizer support for catalog modification operations:
- Handle CreateGraph plan nodes (pass-through to physical)
- Handle DropGraph plan nodes (pass-through to physical)

DDL operations don't require complex optimization, so they directly
convert from logical to physical plans.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement full executor support for DDL operations:

CreateGraphBuilder:
- Handles Create/CreateIfNotExists/CreateOrReplace semantics
- Creates MemoryGraphTypeCatalog from BoundGraphElementType
- Registers labels and builds label registry (LabelId → String)
- Resolves NodeTypeRef (Alias/Filler/Empty) to VertexTypeRef
- Creates MemoryVertexTypeCatalog and MemoryEdgeTypeCatalog
- Adds graph to schema catalog with GraphStorage

DropGraphBuilder:
- Handles if_exists flag
- Removes graph from schema catalog

Key implementation details:
- Two-pass label registration to handle forward references
- Label registry to map LabelId back to strings for catalog
- resolve_vertex_type_from_node_ref() for flexible node type resolution
- get_or_create_vertex_type_by_name() for alias resolution
- Full compatibility with minigu_catalog LabelSet and provider traits

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@XL-Zhao-23 XL-Zhao-23 force-pushed the feature/issue-124-basic-ddl branch 9 times, most recently from 1e9f546 to b99d7fe Compare January 17, 2026 07:48
Add end-to-end test for CREATE GRAPH and DROP GRAPH:

Test case (create_drop_graph.gql):
- CREATE GRAPH with vertex types (Person, City)
- CREATE GRAPH with edge type (Person)-[:LIVES_IN]->(City)
- DROP GRAPH to clean up

Test verifies:
- Complete DDL flow from parsing to execution
- Graph type catalog creation with LabelSet
- Vertex and edge type registration
- NodeTypeRef resolution (Alias references)
- Proper catalog cleanup with DROP GRAPH

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@XL-Zhao-23 XL-Zhao-23 force-pushed the feature/issue-124-basic-ddl branch from b99d7fe to aa4cdb5 Compare January 17, 2026 07:59
@XL-Zhao-23 XL-Zhao-23 marked this pull request as ready for review January 17, 2026 08:05
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