Skip to content

fix(salesforce): export OSI metrics as semanticCalculatedMeasurements - #402

Open
Ashfaqbs wants to merge 1 commit into
apache:mainfrom
Ashfaqbs:fix/export-ossie-metrics-to-salesforce
Open

Ashfaqbs wants to merge 1 commit into
apache:mainfrom
Ashfaqbs:fix/export-ossie-metrics-to-salesforce

Conversation

@Ashfaqbs

Copy link
Copy Markdown

Summary

Fixes #399. MetricMappingHandler.mapOssieToSalesforce() was a stub that discarded every metric mapping and returned without writing to outputData, so an Ossie model's metrics[] never appeared in the exported Salesforce semanticCalculatedMeasurements, even though mappings.yaml already declared metrics.name/metrics.description and the reverse (SF→Ossie) direction was fully implemented.

Changes

  • Wire mapOssieToSalesforce() up to the existing GenericMappingEngine.applyMappings() (same pattern DatasetMappingHandler/RelationshipMappingHandler already use), so name/description map through the declared config instead of being silently dropped.
  • Add unwrapExpressions(), mirroring the existing wrapExpressions() on the SF→Ossie side: flattens each metric's expression.dialects[] into the Salesforce expression string field, and maps datatype via the existing SalesforceDataTypeMapper.
  • Dialect preference: TABLEAU first (what Salesforce/Tableau CRM actually speaks), falling back to ANSI_SQL unresolved/untranslated when there's no TABLEAU entry (logged as a warning). Actually resolving/rewriting an expression into TABLEAU syntax is out of scope here -- that's Adds a SqlGlot implementation of the OSI SQL dialect #222's expression-language engine (ossie_sql), which is Python and still open/unmerged, with no cross-language story yet for using it from this Java converter. This scope was proposed and left open on Salesforce converter drops OSI metrics during export #399 before starting.
  • A metric with neither a TABLEAU nor ANSI_SQL expression fails the conversion with an error naming the metric, rather than being silently omitted -- per Salesforce converter drops OSI metrics during export #399's proposed behavior.

Test plan

  • Added testMetricsConvertedToSemanticCalculatedMeasurements (name/description/datatype/expression all present, exercising the existing fixture's ANSI_SQL-only metrics via the fallback path).
  • Added testMetricExpressionPrefersTableauDialectOverAnsiSql (TABLEAU wins when both dialects are present).
  • Added testMetricWithNoConvertibleDialectFailsConversion (a metric with a schema-valid dialect that is neither TABLEAU nor ANSI_SQL fails loudly and names the metric).
  • Replaced testMetricsNotConvertedInOssieToSalesforce, which asserted the bug (assertNull on semanticCalculatedMeasurements) as the expected behavior.
  • mvn test on converters/salesforce: 55 run, 0 failures, 0 errors (14 skipped -- pre-existing, gated on the Salesforce JSON schema file not being present in this environment; unrelated to this change).

MetricMappingHandler.mapOssieToSalesforce() was a stub that discarded
every metric mapping and returned without writing anything, so an
Ossie model's metrics never appeared in the exported Salesforce
semanticCalculatedMeasurements.

Wire up the existing generic name/description mapping (mappings.yaml
already declared metrics.name/metrics.description, unused until now),
and add unwrapExpressions() to flatten each metric's expression into a
Salesforce-compatible string. TABLEAU is preferred when present since
that is what Salesforce/Tableau CRM speaks; a model authored without
one falls back to its ANSI_SQL expression unresolved/untranslated,
since actually resolving/rewriting into TABLEAU syntax depends on
apache#222's still-open expression-language work, not this fix. A metric
with neither dialect fails the conversion with an actionable error
naming the metric, rather than being silently dropped.

Fixes apache#399
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.

Salesforce converter drops OSI metrics during export

1 participant