[OSSIE][DATABRICKS] Add Databricks Unity Catalog Metric View converter - #224
Conversation
|
RE @jbonofre 's review on #178:
Renaming either would be a bug, not a cleanup. 2, Duplicate dimension/measure name is now a |
jbonofre
left a comment
There was a problem hiding this comment.
I think the json.JSONDecodeError leak is worth to fix.
| """ | ||
| for ext in (obj or {}).get("custom_extensions") or []: | ||
| if ext.get("vendor_name") == VENDOR: | ||
| data = json.loads(ext.get("data") or "{}") |
There was a problem hiding this comment.
If someone edits (by hand) an Apache Ossie file and produces invalid JSON in a custom_extensions[DATABRICKS].data field, this raises a raw json.JSONDecodeError traceback rather than a ConversionError.
Maybe worth to wrap like this:
| data = json.loads(ext.get("data") or "{}") | |
| try: | |
| data = json.loads(ext.get("data") or "{}") | |
| except json.JSONDecodeError as e: | |
| raise ConversionError(f"DATABRICKS custom_extensions data is not valid JSON: {e}") from e |
There was a problem hiding this comment.
Ah good catch, fixed!
| import yaml | ||
|
|
||
| # Apache Ossie semantic model spec version this converter targets (see core-spec). | ||
| OSSIE_VERSION = "0.2.0.dev0" |
There was a problem hiding this comment.
The version check in convert_ossie_to_metric_view is exact match, so this converter will silently reject every Apache Ossie file the moment the spec version moves.
The dbt converter avoids this by depending on the apache-ossie package. This converter intentionally has no such dependency (that's ok), but there is no comment flagging that this constant must be updated in lockstep with core-spec.
I would suggest a comment to "track" this.
There was a problem hiding this comment.
Added a comment
| description: Total units sold | ||
| custom_extensions: | ||
| - vendor_name: DATABRICKS | ||
| data: '{"filter": "ss_net_profit > 0"}' |
There was a problem hiding this comment.
write_stash always injects "_v": 1. The equivalent fixtureB_ossie.yaml has "_v": 1, ... in all its blobs. The missing marker means tpcds_ossie.yaml is inconsistent with what the converter actually writes. The canon() helper in _util.py parses JSON to dicts (masking the discrepancy), but a contributor comparing hand-authored fixture output to real converter output will see a difference.
There was a problem hiding this comment.
right, we need to be aligned, fixed!
…icks) Bidirectional, offline converter between Apache Ossie semantic models and Databricks Unity Catalog Metric Views (YAML v1.1), filling the DATABRICKS spoke already listed in converters/README.md. Packaged like the sibling spokes: pyproject.toml (apache-ossie-databricks), an ossie_databricks package under src/, ASF license headers, and a tests/ suite (example-based + Hypothesis property-based round-trip; 74 tests). PyYAML is the only runtime dependency. Co-authored-by: jackstein21 <82542300+jackstein21@users.noreply.github.com>
4eae5d0 to
ec0436e
Compare
jbonofre
left a comment
There was a problem hiding this comment.
That's a great contribution! Thanks!
Add Databricks Unity Catalog Metric View converter
Adds a bidirectional, offline converter between Apache Ossie semantic models and Databricks Unity Catalog Metric Views (YAML v1.1), filling the Databricks spoke in the hub-and-spoke architecture (
DATABRICKSis already a listed vendor inconverters/index.md). Validated against the live Databricks Metric View engine.What's included
ossie-databricks export): Apache Ossie semantic model -> Metric View (one factsource+ a nestedjoinstree, flatteneddimensions,measures).ossie-databricks import): Metric View -> Apache Ossie. Metric-View-only features (filter, window, format, rely, cardinality, parameters, materialization) are preserved incustom_extensions[DATABRICKS], soMV -> Apache Ossie -> MVis lossless.ossie-databricksCLI and a string-in / string-out Python API.Design highlights
custom_extensions[DATABRICKS]stash -- the approach the converter guide recommends.joinstree; a dataset reached by multiple paths (a diamond) is fanned out into one aliased join per path; cyclic graphs are rejected.many_to_one/one_to_manyis derived from the relationshipfrom/todirection relative to a selectable grain (--source). Multiple facts are supported only narrowly -- when they share a conformed dimension (named as the source); a general galaxy schema (facts each with their own dimensions) or facts sharing no dimension can't map to one Metric View and are rejected with a clear error, never silently mis-converted.primary_key/unique_keyswhose columns cover a join key becomesrely: {at_most_one_match: true}, and vice versa.ConversionError; anything dropped (a foreign-vendor extension, an Apache-Ossie-only annotation, a non-DATABRICKS/ANSI_SQL dialect) emits a warning naming the object.Conventions followed
converters/databricks/, packaged like the dbt/gooddata spokes:pyproject.toml(hatchling, Apache-2.0),src/ossie_databricks/,tests/.DATABRICKS, falls back toANSI_SQL.Testing
Example-based unit tests plus Hypothesis property-based round-trip tests in both directions, with a normalized TPC-DS fixture as a baseline.
Notes
custom_extensionshave no slot in the Metric View YAML; they are dropped on export with a warning.Credits
@jackstein21 is credited as a co-contributor (see the commit's
Co-authored-bytrailer), including the property-based round-trip testing approach.Related Issues
Will close #178, Ossie <-> Databricks converters will be tracked here.
Checklist
Specification
core-spec/and follow the existing structureOntology
ontology/are consistent with spec changesConverters
converters/is updated to reflect spec or ontology changesValidation
validation/are updated if the spec changedDocumentation
docs/is updated to reflect any user-facing changesCONTRIBUTING.mdis updated if the contribution process changedExamples
examples/are added or updated for any new spec constructs or converter supportTests
pytest/ CI green)Compliance