Skip to content

Conversation

@Yuan325
Copy link
Contributor

@Yuan325 Yuan325 commented Feb 2, 2024

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@Yuan325 Yuan325 self-assigned this Feb 2, 2024
@Yuan325 Yuan325 requested a review from a team as a code owner February 2, 2024 21:45
@Yuan325 Yuan325 marked this pull request as draft February 2, 2024 21:45
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/langchain-google-spanner-python API. label Feb 6, 2024
@Yuan325 Yuan325 marked this pull request as ready for review February 9, 2024 23:48
@Yuan325 Yuan325 force-pushed the doc-loader branch 3 times, most recently from 12cfd97 to 96b9b00 Compare February 10, 2024 03:33
@Yuan325 Yuan325 changed the title add document loader feat: add document loader Feb 12, 2024
@kurtisvg kurtisvg requested a review from averikitsch February 14, 2024 15:47
@kurtisvg kurtisvg assigned averikitsch and unassigned Yuan325 Feb 14, 2024
@Yuan325 Yuan325 force-pushed the doc-loader branch 4 times, most recently from 09172ac to 6706a5d Compare February 16, 2024 01:59
@Yuan325 Yuan325 force-pushed the doc-loader branch 3 times, most recently from 7188997 to 78d1aab Compare February 17, 2024 00:35
@Yuan325 Yuan325 requested a review from averikitsch February 17, 2024 00:35
@Yuan325 Yuan325 force-pushed the doc-loader branch 2 times, most recently from 10c2257 to 9b7b9c4 Compare February 17, 2024 01:26
@Yuan325 Yuan325 force-pushed the doc-loader branch 2 times, most recently from 169a5ea to 8315d9d Compare February 21, 2024 00:50
if type(self.staleness) is float
else None
)
snapshot = db.batch_snapshot(exact_staleness=duration, read_timestamp=timestamp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we are passing both? we can just check and pass, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or the other should be "None", therefore simplifying the code by not needing conditionals.

if type(self.staleness) is float
else None
)
snapshot = db.batch_snapshot(exact_staleness=duration, read_timestamp=timestamp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should support all the four options:

  • read_timestamp: Optional[datetime.datetime] = None,
  • min_read_timestamp: Optional[datetime.datetime] = None,
  • max_staleness: Optional[datetime.timedelta] = None,
  • exact_staleness: Optional[datetime.timedelta] = None,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design was scoped to just read_timestamp and exact_staleness

)
for doc in documents
]
keys = [[doc[0]] for doc in docs]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it won't work if the primary key is composite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added another argument in DocumentSaver -- primary key. and used that to build the self._table_fields in the init method. The self._table_fields will be built such as the primary key is always the first in the list. This will ensure that the first field in the tuple will always be the primary key. Thank you for the review!

@averikitsch averikitsch merged commit 7a77d26 into main Feb 22, 2024
@averikitsch averikitsch deleted the doc-loader branch February 22, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/langchain-google-spanner-python API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants