Skip to content

Commit 3e00917

Browse files
authored
Merge pull request #738 from RafalSkolasinski/self-managed-custom-database-name
add cloud architecture test for custom database name
2 parents 1f8fdec + cb7435f commit 3e00917

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

graphdatascience/session/aura_graph_data_science.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ def create(
6868
)
6969

7070
db_bolt_query_runner = Neo4jQueryRunner.create(
71-
db_connection_info.uri, db_connection_info.auth(), aura_ds=True, show_progress=False
71+
db_connection_info.uri,
72+
db_connection_info.auth(),
73+
aura_ds=True,
74+
show_progress=False,
75+
database=db_connection_info.database,
7276
)
7377
db_bolt_query_runner.set_bookmarks(bookmarks)
7478

graphdatascience/session/dbms_connection_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4-
from typing import Tuple
4+
from typing import Optional, Tuple
55

66

77
@dataclass
@@ -13,6 +13,7 @@ class DbmsConnectionInfo:
1313
uri: str
1414
username: str
1515
password: str
16+
database: Optional[str] = None
1617

1718
def auth(self) -> Tuple[str, str]:
1819
"""

graphdatascience/tests/integration/test_remote_graph_ops.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ def test_remote_projection(gds_with_cloud_setup: AuraGraphDataScience) -> None:
4343
assert result["nodeCount"] == 3
4444

4545

46+
@pytest.mark.cloud_architecture
47+
@pytest.mark.compatible_with(min_inclusive=ServerVersion(2, 7, 0))
48+
def test_remote_projection_and_writeback_custom_database_name(gds_with_cloud_setup: AuraGraphDataScience) -> None:
49+
gds_with_cloud_setup.run_cypher("CREATE DATABASE test1234 IF NOT EXISTS")
50+
gds_with_cloud_setup.set_database("test1234")
51+
gds_with_cloud_setup.run_cypher("CREATE ()-[:T]->()")
52+
G, projection_result = gds_with_cloud_setup.graph.project(
53+
GRAPH_NAME, "MATCH (n)-->(m) RETURN gds.graph.project.remote(n, m)"
54+
)
55+
56+
assert G.name() == GRAPH_NAME
57+
assert projection_result["nodeCount"] == 2
58+
assert projection_result["relationshipCount"] == 1
59+
60+
write_result = gds_with_cloud_setup.wcc.write(G, writeProperty="wcc")
61+
62+
assert write_result["nodePropertiesWritten"] == 2
63+
count_wcc_nodes_query = "MATCH (n WHERE n.wcc IS NOT NULL) RETURN count(*) AS c"
64+
nodes_with_wcc_custom_db = gds_with_cloud_setup.run_cypher(count_wcc_nodes_query).squeeze()
65+
assert nodes_with_wcc_custom_db == 2
66+
gds_with_cloud_setup.set_database("neo4j")
67+
# we get a warning because property wcc doesn't exist in the database -- which is good!
68+
with pytest.warns(RuntimeWarning):
69+
nodes_with_wcc_default_db = gds_with_cloud_setup.run_cypher(count_wcc_nodes_query).squeeze()
70+
assert nodes_with_wcc_default_db == 0
71+
72+
4673
@pytest.mark.cloud_architecture
4774
@pytest.mark.compatible_with(min_inclusive=ServerVersion(2, 7, 0))
4875
def test_remote_projection_with_small_batch_size(gds_with_cloud_setup: AuraGraphDataScience) -> None:

0 commit comments

Comments
 (0)