Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -28,4 +28,4 @@ substitutions:

images:
- '${_AR_REPO_URL}/${_IMAGE_NAME}:${_TAG}'
- '${_AR_REPO_URL}/${_IMAGE_NAME}:latest'
- '${_AR_REPO_URL}/${_IMAGE_NAME}:latest'
1 change: 1 addition & 0 deletions import-automation/workflow/ingestion-helper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ build-backend = "hatchling.build"
[project]
name = "ingestion-helper"
version = "0.1.0"
requires-python = ">=3.12"
description = "Ingestion helper for Data Commons Spanner ingestion"
dependencies = [
"functions-framework==3.*",
Expand Down
4 changes: 4 additions & 0 deletions import-automation/workflow/ingestion-helper/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ CREATE TABLE VariableMetadata (
place_types ARRAY<STRING(1024)>,
) PRIMARY KEY(variable_measured, import_name);

CREATE INDEX InEdge ON Edge(object_id, predicate, subject_id, provenance) OPTIONS (
columnar_policy = 'enabled'
);
Comment thread
gmechali marked this conversation as resolved.

CREATE INDEX VariableMeasuredObservationAbout ON Observation(variable_measured, observation_about);
9 changes: 6 additions & 3 deletions import-automation/workflow/ingestion-helper/spanner_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def __init__(self,
"""Initializes a Spanner client and connects to a specific database."""
spanner_client = spanner.Client(
project=project_id,
client_options={'quota_project_id': project_id},
client_options={
'quota_project_id': project_id,
'api_endpoint': 'spanner.googleapis.com'
},
disable_builtin_metrics=True)
instance = spanner_client.instance(instance_id)
database = instance.database(database_id)
Expand Down Expand Up @@ -434,7 +437,7 @@ def initialize_database(self, enable_embeddings=False):
query = """
SELECT 'table' as type, table_name as name FROM information_schema.tables WHERE table_schema = ''
UNION ALL
SELECT 'index' as type, index_name as name FROM information_schema.indexes WHERE table_schema = '' AND table_name = 'NodeEmbedding'
SELECT 'index' as type, index_name as name FROM information_schema.indexes WHERE table_schema = '' AND table_name IN ('NodeEmbedding', 'Edge', 'Observation')
Comment thread
gmechali marked this conversation as resolved.
UNION ALL
SELECT 'model' as type, model_name as name FROM information_schema.models WHERE model_schema = ''
"""
Expand Down Expand Up @@ -466,7 +469,7 @@ def initialize_database(self, enable_embeddings=False):
"Node", "Edge", "Observation", "ImportStatus", "IngestionHistory",
"ImportVersionHistory", "IngestionLock", "Cache", "VariableMetadata"
]
required_indexes = []
required_indexes = ["InEdge", "VariableMeasuredObservationAbout"]
required_models = []

if enable_embeddings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def test_initialize_database_all_exist(self, mock_spanner_client):
["table", "IngestionLock"], ["table", "Cache"],
["table", "VariableMetadata"],
["index", "NodeEmbeddingIndex"],
["index", "InEdge"],
["index", "VariableMeasuredObservationAbout"],
["model", "NodeEmbeddingModel"]
]

Expand Down
Loading