Skip to content

Commit 7188997

Browse files
committed
address comments
1 parent fd137d2 commit 7188997

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/langchain_google_spanner/loader.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _load_doc_to_row(
7878
doc: Document,
7979
metadata_json_column: str,
8080
parse_json: bool = True,
81-
):
81+
) -> tuple:
8282
"""
8383
Load document to row.
8484
@@ -90,7 +90,7 @@ def _load_doc_to_row(
9090
JSON object is used to compare with Spanner reads.
9191
"""
9292
doc_metadata = doc.metadata.copy()
93-
row = [doc.page_content]
93+
row = []
9494
# store metadata
9595
for col in table_fields:
9696
if (
@@ -100,6 +100,8 @@ def _load_doc_to_row(
100100
):
101101
row.append(doc_metadata[col])
102102
del doc_metadata[col]
103+
if col == CONTENT_COL_NAME:
104+
row.append(doc.page_content)
103105
if metadata_json_column in table_fields:
104106
metadata_json = {}
105107
if metadata_json_column in doc_metadata:
@@ -118,7 +120,7 @@ def _batch(datas: List[Any], size: int = 1) -> Iterator[List[Any]]:
118120

119121

120122
class SpannerLoader(BaseLoader):
121-
"""Loads data from Google CLoud Spanner."""
123+
"""Loads data from Google Cloud Spanner."""
122124

123125
def __init__(
124126
self,
@@ -158,7 +160,7 @@ def __init__(
158160
self.metadata_json_column = metadata_json_column
159161
formats = ["JSON", "text", "YAML", "CSV"]
160162
if self.format not in formats:
161-
raise Exception("Use on of 'text', 'JSON', 'YAML', 'CSV'")
163+
raise Exception("Use one of 'text', 'JSON', 'YAML', 'CSV'")
162164
self.databoost = databoost
163165
self.client = client
164166
self.staleness = staleness

tests/integration/test_spanner_loader.py renamed to tests/test_spanner_loader.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
from google.cloud.spanner import Client, KeySet # type: ignore
2020
from langchain_core.documents import Document
2121

22-
from langchain_google_spanner.loader import (
23-
Column,
24-
SpannerDocumentSaver,
25-
SpannerLoader,
26-
)
22+
from langchain_google_spanner.loader import Column, SpannerDocumentSaver, SpannerLoader
2723

2824
project_id = os.environ["PROJECT_ID"]
2925
instance_id = os.environ["INSTANCE_ID"]

0 commit comments

Comments
 (0)