Repository navigation
Description
Summary
Add a gm import-dataplex-glossary command to bigquery_ontology (backed by an optional bigquery-agent-analytics[dataplex] extra) that imports a Google Cloud Knowledge Catalog (formerly Dataplex Universal Catalog) Business Glossary via the GA dataplex.googleapis.com v1 API directly into a validated, SKOS-aligned ontology.yaml.
Once imported, the generated ontology plugs directly into gm validate, gm compile --emit-concept-index, and OntologyRuntime / LabelSynonymResolver without requiring teams to maintain separate OWL/Turtle files.
Motivation
Today gm provides validate, compile, scaffold, and import-owl, where import-owl reads local RDF/Turtle or RDF/XML files. In practice, many BigQuery and ADK teams already govern their enterprise domain vocabulary in Knowledge Catalog Business Glossaries (Glossary → GlossaryCategory → GlossaryTerm, plus synonym / related / definition EntryLinks).
With PR #92 (gm compile --emit-concept-index), Issue #58 (OntologyRuntime + LabelSynonymResolver), and PR #579 (OntologyRuntime SKOS traversal and skos:topConceptOf parity), the downstream taxonomy and entity-resolution surface is already in place. Adding a read-only Dataplex Business Glossary importer bridges enterprise glossaries straight into BigQuery concept indexes and trace entity resolution.
(Naming note: using dataplex for the CLI subcommand, optional extra, module, and provenance annotation namespace aligns with Google Cloud's GA API dataplex.googleapis.com, IAM roles roles/dataplex.catalogViewer, and Python client google-cloud-dataplex.)
Proposed CLI & Behavior
gm import-dataplex-glossary \
projects/<project>/locations/<location>/glossaries/<glossary_id> \
[--ontology-name <name>] \
[--include-links] \
[--include-definitions] \
[--max-links-per-term 100] \
[-o ontology.yaml] \
[--json]Mapping to bigquery_ontology / OntologyRuntime
All emitted entities are abstract: true (matching the SKOS-only output of gm import-owl, which already compiles cleanly with gm compile --emit-concept-index):
Dataplex Business Glossary Resource (dataplex.googleapis.com/v1) |
Emitted ontology.yaml |
Downstream concept_index / OntologyRuntime |
|---|---|---|
Glossary |
Root ontology, description, annotations["dataplex:glossary"], annotations["dataplex:uid"] |
Concept scheme identifier |
GlossaryCategory / GlossaryTerm |
Abstract Entity (abstract: true, description) |
Always included in concept_index |
display_name (non-blank) |
annotations["skos:prefLabel"] |
label_kind="pref" (outranks synonym) |
Resource ID (category_id / term_id) |
annotations["skos:notation"] |
label_kind="notation" + lookup_by_notation() |
parent == glossary.name |
skos:topConceptOf + skos:inScheme |
schemes_for() / in_scheme() (PR #579 parity) |
parent == <category.name> |
skos:inScheme + abstract skos_broader relationship |
broader() / narrower() traversal |
entryLinkTypes/synonym (intra-glossary, with --include-links) |
Mutual skos:altLabel + abstract skos_exactMatch relationship |
Resolvable via LabelSynonymResolver; aligns with #140 |
entryLinkTypes/related (intra-glossary, with --include-links) |
Deduplicated abstract skos_related relationship |
Symmetric related() traversal |
entryLinkTypes/definition (with --include-definitions) |
annotations["dataplex:defined_assets"] |
Preserves linked BigQuery table/column references |
| Cross-glossary links, orphan parents, and sanitized identifier renames | Preserved as annotations (skos:exactMatch / skos:relatedMatch) + reported in stderr summary |
Exact parity with import-owl's drop-summary contract |
Dependencies, IAM, and Safety
- Optional dependency: Add
dataplex = ["google-cloud-dataplex>=2.13.0"]topyproject.toml, lazy-imported insidesrc/bigquery_ontology/dataplex_glossary_importer.py(mirrorsowl = ["rdflib>=7.0"]; missing extra exits cleanly with code2andcli-missing-dependency). - Read-only IAM: Requires only
roles/dataplex.catalogViewer(no writes to Knowledge Catalog). - Bounded RPCs:
CatalogServiceClient.lookup_entry_linksis opt-in (--include-links/--include-definitions) and paginated with--max-links-per-term(respecting the API'spage_size <= 10limit) to avoid unexpected N+1 latency on large glossaries. - Deterministic output: Entities, relationships, and annotations are deterministically sorted so repeated imports produce byte-identical YAML and stable
compile_fingerprintvalues. - Hermetic tests: All unit, CLI, validation, determinism, and
OntologyRuntime/concept_indexparity tests run offline against fake client protocols (no GCP credentials required in CI).
Non-Goals
- No writes or pushes back to Knowledge Catalog.
- No changes to existing
gm validate,gm compile,gm import-owl, orOntologyRuntimebehavior. - No live-agent turn-time resolution (tracked separately in Epic: Address Remaining Ontology Platform Gaps (Live Agent Resolution, Advanced Resolvers, SHACL, Spanner/MAKO) #93).
Activity
caohy1988 commentedon Nov 26, 2026
Thanks for the detailed write-up, and for following up on #579. A read-only glossary importer fits well next to
gm import-owl, and the mapping you describe works with what's on main today: an ontology in that shape (abstract entities withskos:prefLabel/skos:notation/skos:inScheme/skos:topConceptOfannotations plus abstract broader/related relationships) validates, compiles, andbroader,narrower,related,schemes_forandin_schemebehave the way the issue expects. I'd treat it as a welcome enhancement rather than anything urgent.A few details need adjusting before it turns into a PR:
CatalogServiceClient.lookup_entry_linksfirst shipped in google-cloud-dataplex 2.17.0, so>=2.13.0is too low for the link flags. 2.12.0+ is enough for the glossary, category and term reads.gm compileorOntologyRuntimeon its own, since both take a binding (and--emit-concept-indexneeds a destination table). An entity-less binding does work, but the output then starts with aCREATE PROPERTY GRAPHthat has no node tables. That looks like a gap on our side, but the issue and docs should show the actual supported path from a small nested glossary to usable index rows.import-owldoesn't sanitize identifiers (name collisions are an error) and only emits hierarchy edges whose endpoints it knows, so the sanitize/rename and orphan-parent reporting would be new behavior rather than parity.Two open questions:
namederived from, what's the sanitizing rule, and how are collisions handled, given categories and terms have separate ID spaces? Building names from the full resource identity, keeping the raw leaf ID as the notation, and testing a category and term that normalize to the same name would settle this.--max-links-per-termcap would also undercut the byte-identical output goal.Suggested direction: start with a focused PR covering the glossary, categories, terms, labels and hierarchy, with the mapping as a pure function separate from the API calls and fake-client tests that shuffle and repeat pages to prove output and fingerprints stay stable. Links and definition assets can follow as a separate change. Happy to review it.
seoeunbae commentedon Nov 26, 2026
Thanks @caohy1988, this was very helpful. The first PR is up: #613. It covers the glossary, categories, terms, labels and hierarchy, with the mapping as a pure function (
map_dataplex_glossary) separate from the API wrapper, and tests that shuffle and repeat pages and compare the YAML andcompile_fingerprint. It needs onlygoogle-cloud-dataplex>=2.12.0. The user manual walks a small nested glossary through to concept-index rows (companion binding,--concept-index-table, and the bareCREATE PROPERTY GRAPHheader), and the docs say plainly that sanitizing, renaming and orphan-parent reporting are new behavior compared withimport-owl.On your two questions:
category_<id>orterm_<id>, with every character outside[A-Za-z0-9_]replaced by_. Within one glossary that is the full resource identity, because records from another project, location or glossary are rejected. If two resources of the same kind still collide (terms/net-revenueandterms/net_revenue), both get a_<first 8 hex digits of sha256(raw ID)>suffix, so names do not depend on API order. The raw leaf ID stays inskos:notationand the resource name indataplex:resource. A category and a term that normalize alike are covered by a test.One thing to confirm: I read "labels" as the SKOS labels (display name to
skos:prefLabel, resource ID toskos:notation). The Dataplex resourcelabelskey/value map is not imported. Tell me if you want it.fix(ontology): match Dataplex glossary projects exactly, harden import
fix(ontology): reject nameless GetGlossary, harden -o and page reads
feat(ontology): add gm import-dataplex-glossary for Knowledge Catalog…