|
| 1 | +# clickgraph-tck |
| 2 | + |
| 3 | +openCypher [Technology Compatibility Kit (TCK)](https://github.com/opencypher/openCypher/tree/master/tck) runner for ClickGraph, using the embedded chdb engine. |
| 4 | + |
| 5 | +## Current status |
| 6 | + |
| 7 | +**383 / 402 scenarios passing (95.3%)** — 19 skipped (`@NegativeTests` / `@skip`), 0 failing. |
| 8 | + |
| 9 | +## What it tests |
| 10 | + |
| 11 | +The TCK is the openCypher project's official conformance suite. Each scenario is a Gherkin `.feature` file that specifies a graph setup, a Cypher query, and expected results. This crate runs a subset of those scenarios against ClickGraph's embedded query engine. |
| 12 | + |
| 13 | +**Current coverage** — 402 scenarios across 20 feature files: |
| 14 | + |
| 15 | +| Category | Feature files | Scenarios | |
| 16 | +|----------|--------------|-----------| |
| 17 | +| `MATCH` / `OPTIONAL MATCH` | Match1–3, MatchWhere1–2 | 66 | |
| 18 | +| `RETURN` / `ORDER BY` / `SKIP`+`LIMIT` | Return1–3, ReturnOrderBy1, ReturnSkipLimit1 | 46 | |
| 19 | +| `WITH` | With1–3 | 9 | |
| 20 | +| Aggregation (`count`, `min`, `max`) | Aggregation1–2 | 14 | |
| 21 | +| Boolean expressions | Boolean1 | 7 | |
| 22 | +| Comparison expressions | Comparison1 | 13 | |
| 23 | +| List expressions | List1 | 5 | |
| 24 | +| Null handling | Null1 | 5 | |
| 25 | +| String functions | String1 | 1 | |
| 26 | + |
| 27 | +Scenarios tagged `@NegativeTests`, `@skip`, `@fails`, `@crash`, or `@wip` are skipped. |
| 28 | + |
| 29 | +### Known gaps |
| 30 | + |
| 31 | +Write operations (`SET`, `DELETE`, `MERGE`) are not covered — ClickGraph is a read-query engine. The TCK's write-oriented feature files are not included. |
| 32 | + |
| 33 | +## How it works |
| 34 | + |
| 35 | +1. **Schema generation** — at startup, all `.feature` files are scanned to extract every `CREATE` block. Node labels and relationship types are collected into a universal schema (`SchemaCatalog`), which is written as a ClickGraph YAML schema and used to create `ReplacingMergeTree` tables in chdb. |
| 36 | + |
| 37 | +2. **One chdb session per process** — chdb supports only one active session per process. A single `Database` is created at startup and shared across all scenarios via `LazyLock`. Tables are **truncated** between scenarios rather than recreated. |
| 38 | + |
| 39 | +3. **Test execution** — each scenario follows the standard Cucumber lifecycle: |
| 40 | + - *Given* `an empty graph` / `having executed:` — truncates tables, then runs Cypher `CREATE` statements to populate data |
| 41 | + - *When* `executing query:` — translates Cypher to SQL and executes it via the embedded engine |
| 42 | + - *Then* `the result should be (in any order / in order)` — normalises output (bools, nulls, floats) and compares with the expected Gherkin table |
| 43 | + |
| 44 | +## Running |
| 45 | + |
| 46 | +```bash |
| 47 | +# Requires CLICKGRAPH_CHDB_TESTS=1 to opt in to chdb e2e tests |
| 48 | +CLICKGRAPH_CHDB_TESTS=1 cargo test -p clickgraph-tck --test tck |
| 49 | + |
| 50 | +# Show SQL generated for failing scenarios (written to /tmp/tck_failing_sql.txt) |
| 51 | +CLICKGRAPH_CHDB_TESTS=1 cargo test -p clickgraph-tck --test tck 2>&1 | grep FAIL |
| 52 | +``` |
| 53 | + |
| 54 | +> **Important**: Never run multiple instances of these tests concurrently. chdb is a |
| 55 | +> full in-process ClickHouse engine and is memory-intensive. The test harness caps |
| 56 | +> each session to 4 threads and 4 GiB per query; running several instances in |
| 57 | +> parallel will still saturate available RAM. |
| 58 | +
|
| 59 | +## Adding feature files |
| 60 | + |
| 61 | +1. Copy the `.feature` file from the [openCypher TCK](https://github.com/opencypher/openCypher/tree/master/tck/features) into `tests/features/clauses/` or `tests/features/expressions/`. |
| 62 | +2. Update `tests/features/FEATURES_VERSION` with the source commit. |
| 63 | +3. Run the tests — the schema generator picks up new labels/rel-types automatically. |
| 64 | +4. Tag scenarios that rely on unsupported features with `@skip` and add a comment explaining why. |
| 65 | + |
| 66 | +## Directory structure |
| 67 | + |
| 68 | +``` |
| 69 | +clickgraph-tck/ |
| 70 | +├── Cargo.toml |
| 71 | +└── tests/ |
| 72 | + ├── tck.rs # Cucumber test harness (step definitions, world state) |
| 73 | + ├── create_parser.rs # Re-export of the embedded Cypher CREATE parser |
| 74 | + ├── schema_gen.rs # Universal schema inference from feature files |
| 75 | + ├── result_fmt.rs # Result normalisation and Gherkin table parsing |
| 76 | + └── features/ |
| 77 | + ├── FEATURES_VERSION |
| 78 | + ├── clauses/ # MATCH, WITH, RETURN, ORDER BY, SKIP/LIMIT |
| 79 | + └── expressions/ # Aggregation, Boolean, Comparison, List, Null, String |
| 80 | +``` |
0 commit comments