Skip to content

Add description to embeddings for aggregation helper - #753

Open
shixiao-coder wants to merge 18 commits into
datacommonsorg:masterfrom
shixiao-coder:add-description-to-embeddings-for-aggregation-helper
Open

Add description to embeddings for aggregation helper#753
shixiao-coder wants to merge 18 commits into
datacommonsorg:masterfrom
shixiao-coder:add-description-to-embeddings-for-aggregation-helper

Conversation

@shixiao-coder

@shixiao-coder shixiao-coder commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This PR separate the add descriptions changes between aggregation-helper and ingestion-helper from #732

This PR optimize the aggregation-helper to embed descriptions and optimize related tests

@codacy-production

codacy-production Bot commented Sep 3, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 5 high · 3 medium · 2 minor

Alerts:
⚠ 10 issues (≤ 0 issues of at least minor severity)

Results:
10 new issues

Category Results
Compatibility 5 high
Documentation 1 minor
Security 3 medium
CodeStyle 1 minor

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the embedding generation process by migrating from a BigQuery-native approach to a Spanner-first extraction method. It introduces a new _generate_spanner_query method to construct GQL queries, streams results from Spanner to BigQuery using pandas, and updates the EmbeddingSpec to support a dictionary-based node_types structure. The review feedback highlights critical issues including an incorrect Spanner SQL syntax for JSON_OBJECT, a potential resource leak due to missing input validation, a duplicate test assertion, and a requirement to handle the reconstruction of JSON properties during the streaming phase.

Comment thread pipeline/workflow/aggregation-helper/aggregation/aggregation_test.py Outdated
Comment on lines +309 to +314
emb_content = row[2]
if isinstance(emb_content, str):
try:
emb_content = json.loads(emb_content)
except Exception:
pass

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To support the Spanner-compatible array of structs format for properties, we should convert the list of key-value structs into a dictionary in Python before loading the data into BigQuery. Ensure that the final data is serialized back to a JSON string, as database clients expect JSON-serialized strings by design.

                emb_content = row[2]
                if isinstance(emb_content, str):
                    try:
                        data = json.loads(emb_content)
                        if isinstance(data, dict) and "properties" in data:
                            props = data["properties"]
                            if isinstance(props, list):
                                data["properties"] = {p["key"]: p["value"] for p in props if p and "key" in p}
                        emb_content = json.dumps(data)
                    except Exception:
                        pass
References
  1. When passing JSON data to Spanner (or other database clients) that expects JSON-serialized strings by design, do not replace the serialized strings with Python dictionaries or OrderedDict objects, as the serialized format is required for proper database ingestion.

…est.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant