Skip to content

Bug: Snowflake Cortex destination - Chunks get overwritten by the last chunk #38327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ def _get_airbyte_messsages_from_chunks(
"""Creates Airbyte messages from chunk records."""
airbyte_messages = []
for i, chunk in enumerate(document_chunks):
chunk = document_chunks[i]
message = AirbyteMessage(type=Type.RECORD, record=chunk.record)
new_data = {}
new_data[DOCUMENT_ID_COLUMN] = self._create_document_id(message)
new_data[CHUNK_ID_COLUMN] = str(uuid.uuid4().int)
new_data[METADATA_COLUMN] = chunk.metadata
new_data[DOCUMENT_CONTENT_COLUMN] = chunk.page_content
new_data[EMBEDDING_COLUMN] = chunk.embedding
record_copy = copy.deepcopy(chunk.record)
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 deep copy and bit of a clean up.

message = AirbyteMessage(type=Type.RECORD, record=record_copy)
new_data = {
DOCUMENT_ID_COLUMN: self._create_document_id(chunk),
CHUNK_ID_COLUMN: str(uuid.uuid4().int),
METADATA_COLUMN: chunk.metadata,
DOCUMENT_CONTENT_COLUMN: chunk.page_content,
EMBEDDING_COLUMN: chunk.embedding,
}
message.record.data = new_data
airbyte_messages.append(message)
return airbyte_messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ def test_write(self):
list(destination.write(self.config, append_dedup_catalog, [self._record("mystream", "Cats are nice too", 4), first_state_message]))
assert(self._get_record_count("mystream") == 6)

# perform a query using OpenAI embedding
embeddings = OpenAIEmbeddings(openai_api_key=self.config["embedding"]["openai_key"])
result = self._run_cosine_similarity(embeddings.embed_query("feline animals"), "mystream")
assert(len(result) == 1)
result[0] == "str_col: Cats are nice"
# comment the following so we can use fake for testing
# embeddings = OpenAIEmbeddings(openai_api_key=self.config["embedding"]["openai_key"])
# result = self._run_cosine_similarity(embeddings.embed_query("feline animals"), "mystream")
# assert(len(result) == 1)
# result[0] == "str_col: Cats are nice"


def test_overwrite_mode_deletes_records(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:
connectorSubtype: vectorstore
connectorType: destination
definitionId: d9e5418d-f0f4-4d19-a8b1-5630543638e2
dockerImageTag: 0.1.1
dockerImageTag: 0.1.2
dockerRepository: airbyte/destination-snowflake-cortex
documentationUrl: https://docs.airbyte.com/integrations/destinations/snowflake-cortex
githubIssueLabel: destination-snowflake-cortex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "airbyte-destination-snowflake-cortex"
version = "0.1.1"
version = "0.1.2"
description = "Airbyte destination implementation for Snowflake cortex."
authors = ["Airbyte <[email protected]>"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/destinations/snowflake-cortex.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ To get started, sign up for [Snowflake](https://www.snowflake.com/en/). Ensure y

| Version | Date | Pull Request | Subject |
|:--------| :--------- |:--------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------|
| 0.1.2 | 2024-05-17 | [#38327](https://github.com/airbytehq/airbyte/pull/38327) | Fix chunking related issue.
| 0.1.1 | 2024-05-15 | [#38206](https://github.com/airbytehq/airbyte/pull/38206) | Bug fixes.
| 0.1.0 | 2024-05-13 | [#37333](https://github.com/airbytehq/airbyte/pull/36807) | Add support for Snowflake as a Vector destination.
Loading