Skip to content

Commit 3e5a6cc

Browse files
author
Sailesh Mukil
committed
SpannerQueryResult: Change 'error' to 'err'
All consumers of SpannerQueryResult expect `err` instead of `error`. Without this fix, failures are silent. With this, they're displayed within the notebook. Thanks to @cqian23 for pointing this out
1 parent cce2b44 commit 3e5a6cc

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

spanner_graphs/cloud_database.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ def execute_query(
117117
results = snapshot.execute_sql(query, params=params, param_types=param_types)
118118
rows = list(results)
119119
except Exception as e:
120-
return {}, [], [], self.schema_json, e
120+
return SpannerQueryResult(
121+
data={},
122+
fields=[],
123+
rows=[],
124+
schema_json=self.schema_json,
125+
err=e
126+
)
121127

122128
fields: List[SpannerFieldInfo] = get_as_field_info_list(results.fields)
123129
data = {field.name: [] for field in fields}
@@ -128,7 +134,7 @@ def execute_query(
128134
fields=fields,
129135
rows=rows,
130136
schema_json=self.schema_json,
131-
error=None
137+
err=None
132138
)
133139

134140
for row_data in rows:
@@ -143,5 +149,5 @@ def execute_query(
143149
fields=fields,
144150
rows=rows,
145151
schema_json=self.schema_json,
146-
error=None
152+
err=None
147153
)

spanner_graphs/database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SpannerQueryResult(NamedTuple):
3737
# An optional field to return the schema as JSON
3838
schema_json: Any | None
3939
# The error message if any
40-
error: Exception | None
40+
err: Exception | None
4141

4242
class SpannerDatabase(ABC):
4343
"""The spanner class holding the database connection"""
@@ -129,7 +129,7 @@ def execute_query(
129129
fields=fields,
130130
rows=rows,
131131
schema_json=self.schema_json,
132-
error=None
132+
err=None
133133
)
134134

135135
for i, row in enumerate(results):
@@ -143,5 +143,5 @@ def execute_query(
143143
fields=fields,
144144
rows=rows,
145145
schema_json=self.schema_json,
146-
error=None
146+
err=None
147147
)

spanner_graphs/graph_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from spanner_graphs.conversion import get_nodes_edges
2727
from spanner_graphs.exec_env import get_database_instance
28-
28+
from spanner_graphs.database import SpannerQueryResult
2929

3030
# Supported types for a property
3131
PROPERTY_TYPE_SET = {

0 commit comments

Comments
 (0)