Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/iql/12_errors/39_unbound_comparison_error.iql.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Switched to knowledge graph: test_unbound_cmp_n12t39
> +data[(1, 10), (2, 20)]
Inserted 2 fact(s) into 'data'.
> bad(X) <- data(X, _), Y > 5
Query execution failed: Variable 'Y' not found in schema ["X", "_ph_data_1"]
Unsafe comparison in rule 'bad': Variable(s) Y not bound by any positive body atom. Bind them in a body atom (e.g. replace a wildcard with the variable) before comparing.
> ?bad(X)
Query execution failed: Variable 'Y' not found in schema ["X", "_ph_data_1"]
No results.
> .kg use default
Switched to knowledge graph: default
> .kg drop test_unbound_cmp_n12t39
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Switched to knowledge graph: test_unbound_cmp_n12t61
> +data[(1,), (2,)]
Inserted 2 fact(s) into 'data'.
> bad(X) <- data(X), Y > 5
Query execution failed: Variable 'Y' not found in schema ["X"]
Unsafe comparison in rule 'bad': Variable(s) Y not bound by any positive body atom. Bind them in a body atom (e.g. replace a wildcard with the variable) before comparing.
> .kg use default
Switched to knowledge graph: default
> .kg drop test_unbound_cmp_n12t61
Expand Down
32 changes: 32 additions & 0 deletions examples/iql/12_errors/71_dead_equality_binding_error.iql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Test: Dead equality binding rejected at rule registration (issue #108)
// An equality whose variable is not connected to any atom or head variable
// binds by assignment for every row instead of filtering. Both the
// persistent and session rule paths must reject it, including clusters
// that reference each other.

.kg create test_dead_eq_n12t71
.kg use test_dead_eq_n12t71

+customer(id: int, name: string, tier: string)
+customer[(1, "ada", "gold"), (2, "bo", "silver")]
+gold_customer(name: string)

// Persistent path: single dead equality
+gold_customer(Name) <- customer(_, Name, _), Tier = "gold"

// Persistent path: duplicated dead equalities must not alibi each other
+gold_customer(Name) <- customer(_, Name, _), Tier = "gold", Tier = "gold"

// Session path: mutual dead pair
bad(X) <- customer(X, _, _), A = B, B = A

// Nothing registered, nothing derived
?gold_customer(Name)

// The legitimate assignment feature still works: bound into the head
+tagged(name: string, label: string)
+tagged(Name, L) <- customer(_, Name, _), L = "hot"
?tagged(Name, L)

.kg use default
.kg drop test_dead_eq_n12t71
42 changes: 42 additions & 0 deletions examples/iql/12_errors/71_dead_equality_binding_error.iql.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Connecting to server at http://127.0.0.1:8080...
Connected!

Server status: healthy
Authenticated as: admin
Current knowledge graph: default

> .kg create test_dead_eq_n12t71
Knowledge graph 'test_dead_eq_n12t71' created.
Switched to knowledge graph: test_dead_eq_n12t71
> .kg use test_dead_eq_n12t71
Switched to knowledge graph: test_dead_eq_n12t71
> +customer(id: int, name: string, tier: string)
Schema for 'customer' registered with 3 columns (persistent)
> +customer[(1, "ada", "gold"), (2, "bo", "silver")]
Inserted 2 fact(s) into 'customer'.
> +gold_customer(name: string)
Schema for 'gold_customer' registered with 1 columns (persistent)
> +gold_customer(Name) <- customer(_, Name, _), Tier = "gold"
Failed to register rule: Unsafe comparison in rule 'gold_customer': Variable(s) Tier appear only in comparisons and are not connected to any body atom or head variable, so the equality binds them instead of filtering and the comparisons cannot affect the result. Bind them in a body atom (e.g. replace a wildcard with the variable) or remove the comparisons.
> +gold_customer(Name) <- customer(_, Name, _), Tier = "gold", Tier = "gold"
Failed to register rule: Unsafe comparison in rule 'gold_customer': Variable(s) Tier appear only in comparisons and are not connected to any body atom or head variable, so the equality binds them instead of filtering and the comparisons cannot affect the result. Bind them in a body atom (e.g. replace a wildcard with the variable) or remove the comparisons.
> bad(X) <- customer(X, _, _), A = B, B = A
Unsafe comparison in rule 'bad': Variable(s) A, B appear only in comparisons and are not connected to any body atom or head variable, so the equality binds them instead of filtering and the comparisons cannot affect the result. Bind them in a body atom (e.g. replace a wildcard with the variable) or remove the comparisons.
> ?gold_customer(Name)
No results.
> +tagged(name: string, label: string)
Schema for 'tagged' registered with 2 columns (persistent)
> +tagged(Name, L) <- customer(_, Name, _), L = "hot"
Rule 'tagged' registered.
> ?tagged(Name, L)
┌───────┬───────┐
│ name │ label │
├───────┼───────┤
│ "ada" │ "hot" │
│ "bo" │ "hot" │
└───────┴───────┘
2 rows
> .kg use default
Switched to knowledge graph: default
> .kg drop test_dead_eq_n12t71
Knowledge graph 'test_dead_eq_n12t71' dropped.
Loading
Loading