Skip to content

fix(sigma): record dropped keys when a relationship's column arrays have unequal length - #406

Open
AmirF194 wants to merge 2 commits into
apache:mainfrom
AmirF194:fix/sigma-relationship-arity-mismatch
Open

AmirF194 wants to merge 2 commits into
apache:mainfrom
AmirF194:fix/sigma-relationship-arity-mismatch

Conversation

@AmirF194

Copy link
Copy Markdown

Summary

_build_relationship paired from_columns/to_columns with a bare zip(), which stops at the shorter array. The OSI schema only requires each array to be non-empty independently, so a compound-key relationship with unequal lengths is legal input, and the extra key column(s) were dropped from the exported Sigma spec with no record of it.

Thread issues into _build_relationship and record a RELATIONSHIP_COLUMN_ARITY_MISMATCH issue when the lengths differ, mirroring the RELATIONSHIP_COLUMN_UNRESOLVED pattern already used for the reverse (Sigma-to-Ossie) direction. The conversion still degrades to the shorter pairing, since Sigma's keys array has no way to represent an unequal-length join, but the loss is now visible in ConverterResult.issues instead of silent.

Related Issues

Fixes #405

Checklist

Converters

  • Converter logic in converters/sigma is updated
  • New tests cover the arity-mismatch case

Tests

  • uv run pytest on Python 3.11, 3.12, 3.14 - 92 passed on each
  • Ran the new test on plain main: it errors there (the issue type doesn't exist yet)

Compliance

  • No new source files, no new dependencies

…ave unequal length

from_columns and to_columns are only constrained independently in the OSI JSON
schema (each just needs at least one entry), so a compound-key relationship with
unequal-length arrays is legal input. _build_relationship paired them with a bare
zip(), which stops at the shorter array and drops the extra key column(s) with no
warning at all.

Thread the issues list into _build_relationship and record a
RELATIONSHIP_COLUMN_ARITY_MISMATCH issue when the lengths differ, mirroring the
RELATIONSHIP_COLUMN_UNRESOLVED pattern already used for the reverse direction. The
converter still degrades to the shorter pairing (Sigma's own keys array has no way
to represent an unequal-length join), but the loss is now visible in the returned
ConverterResult.issues instead of silent.
Copilot AI lite review requested due to automatic review settings September 15, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jbonofre
jbonofre self-requested a review September 16, 2026 14:14
Comment thread converters/sigma/src/ossie_sigma/ossie_to_sigma.py Outdated
Relationship identity is already scoped by (dataset_name, rel.name);
the arity-mismatch ConverterIssue used the bare relationship name,
so two same-named relationships on different table pairs became
indistinguishable when both hit the mismatch.
@AmirF194

Copy link
Copy Markdown
Author

Good catch, fixed: the arity-mismatch issue now uses f"{dataset_name}.{rel.name}" for element_name, matching the relationship id's own scoping. Added test_relationship_arity_mismatch_element_names_are_scoped_by_owning_dataset (two same-named relationships on different table pairs, both arity-mismatched); against the prior code it fails with 1 == 2, both issues collapsing onto "Parent". Full 93-test suite passes in the repo's own verify command. Pushed 633ca26.

@khush-bhatia

Copy link
Copy Markdown
Contributor

@AmirF194 Please see this #375 which was merged recently.
I believe the converter code should be changed to fail this case instead.

if raw_keys is not None:
result["keys"] = raw_keys
else:
if len(rel.from_columns) != len(rel.to_columns):

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.

Now core-spec/spec.md (Relationship) states: "Both arrays must have the same number of columns". It's not something we should warn and proceed, it's a "real" issue.

The PR here handles the identical condition by recording a ConverterIssue and then converting via zip(), which silently truncates to the shorter array. That's inconsistent with the spec statement, and it means a document that skips validate.py gets corrupted output from the converter instead of being rejected.

We already have what we need: converter_issues.py defines ConverterError, raised when the input cannot converted at all, as opposed to partial, lossy conversion that a ConverterIssue an describe. This file already uses it for structurally invalid input (empty semantic_model).

An arity mismatch is a spec-invalid input, not a legal-but-lossy translation gap like EXPRESSION_NOT_TRANSLATABLE.

I suggest raising ConverterError here instead of appending a ConverterIssue and continuing.

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.

@khush-bhatia FYI, see my request change here (about ConverterError).

@AmirF194

Copy link
Copy Markdown
Author

I'd keep the converter's own handling rather than switch to a hard fail: #375's arity check lives in validation/validate.py, a separate script the docs recommend running before conversion but nothing wires into ossie-sigma's CLI or model_validate() call. A document can reach OssieToSigmaConverter without ever going through that script, so this path is still reachable with real input, not just a defensive-programming guard against something the schema now forbids.

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.

Sigma converter silently drops key columns when a relationship's from_columns/to_columns lengths differ

4 participants