2
2
from pandas import DataFrame
3
3
4
4
from graphdatascience .graph_data_science import GraphDataScience
5
- from graphdatascience .server_version .server_version import ServerVersion
6
5
7
6
from .conftest import CollectingQueryRunner
8
7
9
8
10
- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 1 , 0 )])
11
9
def test_graph_project_based_construct_without_arrow (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
12
10
nodes = DataFrame (
13
11
{
@@ -28,54 +26,22 @@ def test_graph_project_based_construct_without_arrow(runner: CollectingQueryRunn
28
26
runner .add__mock_result ("gds.debug.sysInfo" , DataFrame ([{"gdsEdition" : "Unlicensed" }]))
29
27
gds .graph .construct ("hello" , nodes , relationships , concurrency = 2 )
30
28
31
- expected_node_query = "UNWIND $nodes as node RETURN node[0] as id, node[1] as labels, node[2] as propA"
32
- expected_relationship_query = (
33
- "UNWIND $relationships as relationship RETURN "
34
- "relationship[0] as source, relationship[1] as target, "
35
- "relationship[2] as type, relationship[3] as relPropA"
36
- )
37
- expected_proc_query = (
38
- "CALL gds.graph.project.cypher("
39
- "$graph_name, "
40
- "$node_query, "
41
- "$relationship_query, "
42
- "{readConcurrency: $read_concurrency, parameters: { nodes: $nodes, relationships: $relationships }})"
29
+ expected_query = (
30
+ "UNWIND $data AS data WITH data, "
31
+ "CASE WHEN data[6] THEN data[5] ELSE null END AS sourceNodeLabels, "
32
+ "CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType, "
33
+ "CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId, "
34
+ "\n CASE WHEN data[8] THEN data[7] ELSE null END AS sourceNodeProperties, "
35
+ "\n CASE WHEN data[1] THEN data[0] ELSE null END AS relationshipProperties "
36
+ "RETURN gds.graph.project($graph_name, data[4], targetNodeId, {sourceNodeLabels: sourceNodeLabels, targetNodeLabels: NULL, sourceNodeProperties: sourceNodeProperties, targetNodeProperties: NULL, relationshipType: relationshipType, relationshipProperties: relationshipProperties}, $configuration)"
43
37
)
44
38
45
- assert runner .last_query () == expected_proc_query
46
- assert runner .last_params () == {
47
- "nodes" : nodes .values .tolist (),
48
- "relationships" : relationships .values .tolist (),
49
- "read_concurrency" : 2 ,
50
- "graph_name" : "hello" ,
51
- "node_query" : expected_node_query ,
52
- "relationship_query" : expected_relationship_query ,
53
- }
39
+ assert runner .last_query () == expected_query
54
40
55
41
56
- @pytest .mark .parametrize (
57
- "server_version, tier, target_node_labels, target_node_properties, properties_key, in_between_configs" ,
58
- [
59
- (ServerVersion (2 , 3 , 0 ), ".alpha" , "" , "" , "properties" , "}, {" ),
60
- (
61
- ServerVersion (2 , 4 , 0 ),
62
- "" ,
63
- ", targetNodeLabels: NULL" ,
64
- ", targetNodeProperties: NULL" ,
65
- "relationshipProperties" ,
66
- ", " ,
67
- ),
68
- ],
69
- ids = ["2.3.0 - Alpha Cypher Aggregation" , "2.4.0 - New Cypher projection" ],
70
- )
71
42
def test_multi_df (
72
43
runner : CollectingQueryRunner ,
73
44
gds : GraphDataScience ,
74
- tier : str ,
75
- target_node_labels : str ,
76
- target_node_properties : str ,
77
- properties_key : str ,
78
- in_between_configs : str ,
79
45
) -> None :
80
46
nodes = [
81
47
DataFrame ({"nodeId" : [0 , 1 ], "labels" : ["a" , "a" ], "property" : [6.0 , 7.0 ]}),
@@ -99,13 +65,12 @@ def test_multi_df(
99
65
" CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType,"
100
66
" CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId,"
101
67
" CASE WHEN data[8] THEN data[7] ELSE null END AS sourceNodeProperties,"
102
- f " CASE WHEN data[1] THEN data[0] ELSE null END AS { properties_key } "
103
- f " RETURN gds{ tier } .graph.project("
68
+ " CASE WHEN data[1] THEN data[0] ELSE null END AS relationshipProperties "
69
+ " RETURN gds.graph.project("
104
70
"$graph_name, data[4], targetNodeId, {"
105
- f"sourceNodeLabels: sourceNodeLabels{ target_node_labels } , "
106
- f"sourceNodeProperties: sourceNodeProperties{ target_node_properties } "
107
- f"{ in_between_configs } "
108
- f"relationshipType: relationshipType, { properties_key } : { properties_key } "
71
+ "sourceNodeLabels: sourceNodeLabels, targetNodeLabels: NULL, "
72
+ "sourceNodeProperties: sourceNodeProperties, targetNodeProperties: NULL, "
73
+ "relationshipType: relationshipType, relationshipProperties: relationshipProperties"
109
74
"}, $configuration)"
110
75
)
111
76
@@ -131,29 +96,9 @@ def test_multi_df(
131
96
}
132
97
133
98
134
- @pytest .mark .parametrize (
135
- "server_version, tier, target_node_labels, target_node_properties, properties_key, in_between_configs" ,
136
- [
137
- (ServerVersion (2 , 3 , 0 ), ".alpha" , "" , "" , "properties" , "}, {" ),
138
- (
139
- ServerVersion (2 , 4 , 0 ),
140
- "" ,
141
- ", targetNodeLabels: NULL" ,
142
- ", targetNodeProperties: NULL" ,
143
- "relationshipProperties" ,
144
- ", " ,
145
- ),
146
- ],
147
- ids = ["2.3.0 - Alpha Cypher Aggregation" , "2.4.0 - New Cypher projection" ],
148
- )
149
99
def test_graph_aggregation_based_construct_without_arrow (
150
100
runner : CollectingQueryRunner ,
151
101
gds : GraphDataScience ,
152
- tier : str ,
153
- target_node_labels : str ,
154
- target_node_properties : str ,
155
- properties_key : str ,
156
- in_between_configs : str ,
157
102
) -> None :
158
103
nodes = DataFrame (
159
104
{
@@ -184,13 +129,12 @@ def test_graph_aggregation_based_construct_without_arrow(
184
129
" CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType,"
185
130
" CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId,"
186
131
" CASE WHEN data[8] THEN data[7] ELSE null END AS sourceNodeProperties,"
187
- f " CASE WHEN data[1] THEN data[0] ELSE null END AS { properties_key } "
188
- f " RETURN gds{ tier } .graph.project("
132
+ " CASE WHEN data[1] THEN data[0] ELSE null END AS relationshipProperties "
133
+ " RETURN gds.graph.project("
189
134
"$graph_name, data[4], targetNodeId, {"
190
- f"sourceNodeLabels: sourceNodeLabels{ target_node_labels } , "
191
- f"sourceNodeProperties: sourceNodeProperties{ target_node_properties } "
192
- f"{ in_between_configs } "
193
- f"relationshipType: relationshipType, { properties_key } : { properties_key } "
135
+ "sourceNodeLabels: sourceNodeLabels, targetNodeLabels: NULL, "
136
+ "sourceNodeProperties: sourceNodeProperties, targetNodeProperties: NULL, "
137
+ "relationshipType: relationshipType, relationshipProperties: relationshipProperties"
194
138
"}, $configuration)"
195
139
)
196
140
@@ -213,7 +157,6 @@ def test_graph_aggregation_based_construct_without_arrow(
213
157
}
214
158
215
159
216
- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 3 , 0 )])
217
160
def test_graph_aggregation_based_construct_without_arrow_with_overlapping_property_columns (
218
161
runner : CollectingQueryRunner , gds : GraphDataScience
219
162
) -> None :
@@ -242,7 +185,6 @@ def test_graph_aggregation_based_construct_without_arrow_with_overlapping_proper
242
185
gds .graph .construct ("hello" , nodes , relationships , concurrency = 2 )
243
186
244
187
245
- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 1 , 0 )])
246
188
def test_graph_construct_validate_df_columns (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
247
189
nodes = DataFrame ({"nodeIds" : [0 , 1 ]})
248
190
relationships = DataFrame ({"sourceNodeId" : [0 , 1 ], "TargetNodeIds" : [1 , 0 ]})
@@ -254,7 +196,6 @@ def test_graph_construct_validate_df_columns(runner: CollectingQueryRunner, gds:
254
196
gds .graph .construct ("hello" , nodes , relationships , concurrency = 2 )
255
197
256
198
257
- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 1 , 0 )])
258
199
def test_graph_alpha_construct_backward_compat (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
259
200
nodes = DataFrame (
260
201
{
0 commit comments