Skip to content

fix(salesforce): emit the Tua expression syntax on calculated dimensions - #539

Merged
jbonofre merged 1 commit into
apache:mainfrom
RyutoYoda:fix/salesforce-calculated-dimension-syntax
Oct 9, 2026
Merged

jbonofre merged 1 commit into
apache:mainfrom
RyutoYoda:fix/salesforce-calculated-dimension-syntax

Conversation

@RyutoYoda

@RyutoYoda RyutoYoda commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With #526 and #532 merged an Ossie model now reaches the Salesforce semantic model
API, and this is the next failure it hits. Thanks for the quick reviews on those.

FieldMappingHandler.createSemanticCalculatedDimension writes the Ossie dialect
name as the expression syntax. The API only accepts Tua, so a model carrying
even one calculated dimension is rejected in full:

HTTP 400 POST_BODY_PARSE_ERROR
Invalid value for Invalid Expression Syntax Type: TABLEAU

Calculated measurements already emit Tua in MetricMappingHandler, so only the
dimension path is affected. The round trip breaks for the same reason: syntax
imported from Salesforce is kept in custom_extensions, but
restoreSalesforceCustomExtension does not overwrite a key the export already
wrote, so the stored Tua never comes back.

SYNTAX and SYNTAX_TUA are now named in ConverterConstants and used on both
paths, so the one accepted value lives in a single place.

Salesforce's own published model carries no syntax on its calculated
dimensions, so omitting the key works too; Tua is used here to match the
measurement path.

Verification

Against a live org (v66.0 ssot/semantic/models), one synthetic model with a
single calculated dimension:

syntax result
TABLEAU 400, model rejected
Tua 201, persisted as Tua, isQueryable: Queryable
absent 201, persisted with no syntax

A model generated by the patched converter posts with 201. The Tableau-dialect
expression is passed through unchanged, and the dimension persists with
isQueryable: Queryable; a query grouping by it returns rows, so the text is
evaluated as Tua. Every model created for this was deleted again.

Related Issues

No existing issue covers this.

Checklist

Sections this change does not touch (Specification, Ontology, Validation,
Documentation, Examples) are omitted rather than left unchecked.

Converters

  • Converter logic updated
  • Tests live under the converter's test directory

Tests

  • mvn -B -DrequireSalesforceSchema=true clean verify: 301 tests, 0 failures, 0 errors, 0 skipped; apache-rat:check clean
  • Both new tests fail without the main-code change, with expected: <Tua> but was: <TABLEAU>

Compliance

  • ASF license headers present (no new files added)
  • No third-party dependencies added

A calculated dimension declared the Ossie dialect name as its expression
syntax, which the Salesforce semantic model API rejects with
"Invalid value for Invalid Expression Syntax Type: TABLEAU", failing the
whole model. Calculated measurements already emit "Tua", the only syntax
type the API accepts; name it once and use it on both paths.

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks good overall. Switching calculated dimensions to syntax: Tua and sharing the constants with MetricMappingHandler is consistent, and the export and round-trip tests cover the change.

I have one question: the metric path compiles expressions through the Tua compiler before writing syntax: Tua. createSemanticCalculatedDimension copies the Tableau-style expression through unchanged (e.g. YEAR([Orders].[order_data])) and only relabels it. Is that text already valid Tua, or could Salesforce reject it on import? If it's been verified against a real org, a short note in the PR would be enough. If not, it may be worth running dimension expressions through the same compiler.

I would be happy to approve once that's clarified.

@RyutoYoda

Copy link
Copy Markdown
Contributor Author

Verified against a live org, so I have added the note to the description.

The Tableau text passes through unchanged and is accepted: the model posts 201, the calculated dimension persists with isQueryable: Queryable, and a query grouping by it returns rows. The API validates the expression rather than storing it blindly — a reference to a column the data object does not have comes back as 400 ... The referenced Data Cloud fields ([...]) could not be found.

Reusing the metric compiler is not possible as it stands. Checked on this branch:

  • row level is rejected outright, unaggregated field in metric; use an explicit aggregate, and a calculated dimension is row-level by definition;
  • the result must be numeric and the emitted dataType is Number, while dimensions are usually Text or Date;
  • YEAR([Orders].[order_date]), the expression in this repo's own calculated-dimension fixture, fails with unsupported function YEAR; Salesforce converter: translate OSI metric expressions and validate field references ossie-converters#36 lists date and string functions as later milestones.

@RyutoYoda
RyutoYoda requested a review from jbonofre October 9, 2026 02:18

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks @RyutoYoda!

The fix cleanly aligns calculated dimensions with measurements using ConverterConstants.SYNTAX_TUA, and resolves the round-trip preservation bug. Full test suite and license checks pass cleanly.

@jbonofre
jbonofre merged commit e5d6528 into apache:main Oct 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants