22from pandas import DataFrame
33
44from graphdatascience .graph_data_science import GraphDataScience
5- from graphdatascience .server_version .server_version import ServerVersion
65
76from .conftest import CollectingQueryRunner
87
98
10- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 1 , 0 )])
119def test_graph_project_based_construct_without_arrow (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
1210 nodes = DataFrame (
1311 {
@@ -28,54 +26,22 @@ def test_graph_project_based_construct_without_arrow(runner: CollectingQueryRunn
2826 runner .add__mock_result ("gds.debug.sysInfo" , DataFrame ([{"gdsEdition" : "Unlicensed" }]))
2927 gds .graph .construct ("hello" , nodes , relationships , concurrency = 2 )
3028
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)"
4337 )
4438
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
5440
5541
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- )
7142def test_multi_df (
7243 runner : CollectingQueryRunner ,
7344 gds : GraphDataScience ,
74- tier : str ,
75- target_node_labels : str ,
76- target_node_properties : str ,
77- properties_key : str ,
78- in_between_configs : str ,
7945) -> None :
8046 nodes = [
8147 DataFrame ({"nodeId" : [0 , 1 ], "labels" : ["a" , "a" ], "property" : [6.0 , 7.0 ]}),
@@ -99,13 +65,12 @@ def test_multi_df(
9965 " CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType,"
10066 " CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId,"
10167 " 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("
10470 "$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"
10974 "}, $configuration)"
11075 )
11176
@@ -131,29 +96,9 @@ def test_multi_df(
13196 }
13297
13398
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- )
14999def test_graph_aggregation_based_construct_without_arrow (
150100 runner : CollectingQueryRunner ,
151101 gds : GraphDataScience ,
152- tier : str ,
153- target_node_labels : str ,
154- target_node_properties : str ,
155- properties_key : str ,
156- in_between_configs : str ,
157102) -> None :
158103 nodes = DataFrame (
159104 {
@@ -184,13 +129,12 @@ def test_graph_aggregation_based_construct_without_arrow(
184129 " CASE WHEN data[3] THEN data[2] ELSE null END AS relationshipType,"
185130 " CASE WHEN data[10] THEN data[9] ELSE null END AS targetNodeId,"
186131 " 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("
189134 "$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"
194138 "}, $configuration)"
195139 )
196140
@@ -213,7 +157,6 @@ def test_graph_aggregation_based_construct_without_arrow(
213157 }
214158
215159
216- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 3 , 0 )])
217160def test_graph_aggregation_based_construct_without_arrow_with_overlapping_property_columns (
218161 runner : CollectingQueryRunner , gds : GraphDataScience
219162) -> None :
@@ -242,7 +185,6 @@ def test_graph_aggregation_based_construct_without_arrow_with_overlapping_proper
242185 gds .graph .construct ("hello" , nodes , relationships , concurrency = 2 )
243186
244187
245- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 1 , 0 )])
246188def test_graph_construct_validate_df_columns (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
247189 nodes = DataFrame ({"nodeIds" : [0 , 1 ]})
248190 relationships = DataFrame ({"sourceNodeId" : [0 , 1 ], "TargetNodeIds" : [1 , 0 ]})
@@ -254,7 +196,6 @@ def test_graph_construct_validate_df_columns(runner: CollectingQueryRunner, gds:
254196 gds .graph .construct ("hello" , nodes , relationships , concurrency = 2 )
255197
256198
257- @pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 1 , 0 )])
258199def test_graph_alpha_construct_backward_compat (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
259200 nodes = DataFrame (
260201 {
0 commit comments