gqlite 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/ext/Cargo.toml +8 -8
  3. data/ext/db-index/Cargo.toml +2 -2
  4. data/ext/gqlitedb/Cargo.toml +0 -2
  5. data/ext/gqlitedb/src/aggregators.rs +28 -0
  6. data/ext/gqlitedb/src/compiler/expression_analyser.rs +33 -0
  7. data/ext/gqlitedb/src/compiler/variables_manager.rs +111 -11
  8. data/ext/gqlitedb/src/compiler.rs +506 -48
  9. data/ext/gqlitedb/src/connection.rs +14 -2
  10. data/ext/gqlitedb/src/consts.rs +1 -1
  11. data/ext/gqlitedb/src/error.rs +31 -0
  12. data/ext/gqlitedb/src/interpreter/evaluators.rs +153 -331
  13. data/ext/gqlitedb/src/interpreter/instructions.rs +77 -0
  14. data/ext/gqlitedb/src/interpreter/mod.rs +1 -0
  15. data/ext/gqlitedb/src/interpreter/path/bfs.rs +494 -0
  16. data/ext/gqlitedb/src/interpreter/path/dfs.rs +267 -0
  17. data/ext/gqlitedb/src/interpreter/path/group.rs +418 -0
  18. data/ext/gqlitedb/src/interpreter/path.rs +542 -0
  19. data/ext/gqlitedb/src/planner.rs +231 -6
  20. data/ext/gqlitedb/src/query_result.rs +19 -4
  21. data/ext/gqlitedb/src/store/redb.rs +1 -1
  22. data/ext/gqlitedb/src/tests/compiler.rs +2454 -1
  23. data/ext/gqlitedb/src/tests/connection/postgres.rs +22 -0
  24. data/ext/gqlitedb/src/tests/connection/redb.rs +24 -0
  25. data/ext/gqlitedb/src/tests/connection/sqlite.rs +16 -0
  26. data/ext/gqlitedb/src/tests/connection.rs +101 -0
  27. data/ext/gqlitedb/src/tests/evaluators.rs +2206 -1
  28. data/ext/gqlitedb/src/tests/parser.rs +1225 -0
  29. data/ext/gqlitedb/src/tests/planner.rs +433 -2
  30. data/ext/gqlitedb/src/tests/store/vector_index/postgres.rs +5 -5
  31. data/ext/gqlitedb/src/tests/store/vector_index/sqlite.rs +3 -1
  32. data/ext/gqlitedb/src/tests/templates/ast.rs +294 -1
  33. data/ext/gqlitedb/src/tests/templates/programs.rs +318 -0
  34. data/ext/gqliterb/Cargo.toml +0 -1
  35. data/ext/gqlparser/src/oc/ast.rs +72 -3
  36. data/ext/gqlparser/src/oc/error.rs +18 -0
  37. data/ext/gqlparser/src/oc/lexer.rs +157 -2
  38. data/ext/gqlparser/src/oc/parser/tests.rs +735 -29
  39. data/ext/gqlparser/src/oc/parser.rs +1312 -182
  40. data/ext/gqlparser/src/oc/string.rs +172 -0
  41. data/ext/gqlparser/src/oc.rs +1 -0
  42. data/ext/graphcore/src/value/value_map.rs +2 -2
  43. data/ext/graphcore/src/value.rs +13 -1
  44. metadata +6 -2
  45. data/ext/gqlitedb/src/parser/gql.pest +0 -198
@@ -41,3 +41,25 @@ fn test_vector_search_dimension_mismatch()
41
41
  let connection = builder.create().unwrap();
42
42
  super::test_vector_search_dimension_mismatch(connection);
43
43
  }
44
+
45
+ #[test]
46
+ fn test_not_wraps_comparison_at_runtime()
47
+ {
48
+ let db = crate::tests::postgres::create_tmp_db(14);
49
+ let builder = crate::Connection::builder()
50
+ .set_option("url", db.connection_uri())
51
+ .backend(crate::Backend::Postgres);
52
+ let connection = builder.create().unwrap();
53
+ super::test_not_wraps_comparison_at_runtime(connection);
54
+ }
55
+
56
+ #[test]
57
+ fn test_count_distinct_end_to_end()
58
+ {
59
+ let db = crate::tests::postgres::create_tmp_db(15);
60
+ let builder = crate::Connection::builder()
61
+ .set_option("url", db.connection_uri())
62
+ .backend(crate::Backend::Postgres);
63
+ let connection = builder.create().unwrap();
64
+ super::test_count_distinct_end_to_end(connection);
65
+ }
@@ -21,3 +21,27 @@ fn test_create_edge_return()
21
21
  let connection = builder.create().unwrap();
22
22
  super::test_create_edge_return(connection);
23
23
  }
24
+
25
+ #[test]
26
+ fn test_not_wraps_comparison_at_runtime()
27
+ {
28
+ let builder = crate::Connection::builder().backend(crate::Backend::Redb);
29
+ let connection = builder.create().unwrap();
30
+ super::test_not_wraps_comparison_at_runtime(connection);
31
+ }
32
+
33
+ #[test]
34
+ fn test_count_distinct_end_to_end()
35
+ {
36
+ let builder = crate::Connection::builder().backend(crate::Backend::Redb);
37
+ let connection = builder.create().unwrap();
38
+ super::test_count_distinct_end_to_end(connection);
39
+ }
40
+
41
+ #[test]
42
+ fn test_shortest_with_explicit_minimum_hop_count()
43
+ {
44
+ let builder = crate::Connection::builder().backend(crate::Backend::Redb);
45
+ let connection = builder.create().unwrap();
46
+ super::test_shortest_with_explicit_minimum_hop_count(connection);
47
+ }
@@ -29,3 +29,19 @@ fn test_vector_search_dimension_mismatch()
29
29
  let connection = builder.create().unwrap();
30
30
  super::test_vector_search_dimension_mismatch(connection);
31
31
  }
32
+
33
+ #[test]
34
+ fn test_not_wraps_comparison_at_runtime()
35
+ {
36
+ let builder = crate::Connection::builder().backend(crate::Backend::SQLite);
37
+ let connection = builder.create().unwrap();
38
+ super::test_not_wraps_comparison_at_runtime(connection);
39
+ }
40
+
41
+ #[test]
42
+ fn test_count_distinct_end_to_end()
43
+ {
44
+ let builder = crate::Connection::builder().backend(crate::Backend::SQLite);
45
+ let connection = builder.create().unwrap();
46
+ super::test_count_distinct_end_to_end(connection);
47
+ }
@@ -77,3 +77,104 @@ fn test_vector_search_dimension_mismatch(connection: crate::Connection)
77
77
  );
78
78
  assert!(result.is_err(), "dimension mismatch should raise an error");
79
79
  }
80
+
81
+ fn test_not_wraps_comparison_at_runtime(connection: crate::Connection)
82
+ {
83
+ connection
84
+ .execute_oc_query("CREATE (:Person {name: \"Alice\"})", Default::default())
85
+ .unwrap();
86
+ connection
87
+ .execute_oc_query("CREATE (:Person {name: \"Bob\"})", Default::default())
88
+ .unwrap();
89
+
90
+ let result = connection
91
+ .execute_oc_query(
92
+ r#"MATCH (p:Person) WHERE NOT p.name = "Alice" RETURN count(p) AS n"#,
93
+ Default::default(),
94
+ )
95
+ .unwrap();
96
+ let table = result.try_into_table().unwrap();
97
+ assert_eq!(table.rows(), 1);
98
+ let count: i64 = table.value(0, 0).unwrap().try_into().unwrap();
99
+ assert_eq!(count, 1, "only Bob should match (NOT Alice)");
100
+ }
101
+
102
+ fn test_count_distinct_end_to_end(connection: crate::Connection)
103
+ {
104
+ connection
105
+ .execute_oc_query("CREATE (:Person {id: 1})", Default::default())
106
+ .unwrap();
107
+ connection
108
+ .execute_oc_query("CREATE (:Person {id: 2})", Default::default())
109
+ .unwrap();
110
+ connection
111
+ .execute_oc_query("CREATE (:Person {id: 3})", Default::default())
112
+ .unwrap();
113
+
114
+ connection
115
+ .execute_oc_query(
116
+ "MATCH (p:Person {id: 1}), (f:Person) CREATE (p)-[:KNOWS]->(f)",
117
+ Default::default(),
118
+ )
119
+ .unwrap();
120
+ connection
121
+ .execute_oc_query(
122
+ "MATCH (p:Person {id: 1}), (f:Person {id: 2}) CREATE (p)-[:KNOWS]->(f)",
123
+ Default::default(),
124
+ )
125
+ .unwrap();
126
+ connection
127
+ .execute_oc_query(
128
+ "MATCH (p:Person {id: 1}), (f:Person {id: 3}) CREATE (p)-[:KNOWS]->(f)",
129
+ Default::default(),
130
+ )
131
+ .unwrap();
132
+
133
+ let result = connection
134
+ .execute_oc_query(
135
+ "MATCH (p:Person {id: 1})-[:KNOWS]->(friend:Person) RETURN count(DISTINCT friend) AS n",
136
+ Default::default(),
137
+ )
138
+ .unwrap();
139
+ let table = result.try_into_table().unwrap();
140
+ assert_eq!(table.rows(), 1);
141
+ let count: i64 = table.value(0, 0).unwrap().try_into().unwrap();
142
+ assert_eq!(count, 3, "should count distinct friends");
143
+ }
144
+
145
+ fn test_shortest_with_explicit_minimum_hop_count(connection: crate::Connection)
146
+ {
147
+ connection
148
+ .execute_oc_query(
149
+ r#"
150
+ CREATE (a:Station {name: 'A'}),
151
+ (x:Station {name: 'X'}),
152
+ (d:Station {name: 'D'}),
153
+ (a)-[:LINK]->(d),
154
+ (a)-[:LINK]->(x),
155
+ (x)-[:LINK]->(d)
156
+ "#,
157
+ Default::default(),
158
+ )
159
+ .unwrap();
160
+
161
+ let result = connection
162
+ .execute_oc_query(
163
+ r#"MATCH p = SHORTEST 1 (a:Station {name: 'A'})-[:LINK*2..4]->(d:Station {name: 'D'}) RETURN length(p) AS len"#,
164
+ Default::default(),
165
+ )
166
+ .unwrap();
167
+
168
+ let table = result.try_into_table().unwrap();
169
+ assert_eq!(
170
+ table.rows(),
171
+ 1,
172
+ "should find exactly one path with min_hops=2, got {} rows",
173
+ table.rows()
174
+ );
175
+ let len: i64 = table.value(0, 0).unwrap().try_into().unwrap();
176
+ assert_eq!(
177
+ len, 2,
178
+ "should return path of length 2 (A->X->D), not the direct 1-hop edge (A->D)"
179
+ );
180
+ }