Repository navigation
Respect explicitly declared constraintProperties on StatVars - #795
Merged
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 34 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the MCF mutation and name generation logic to respect explicitly declared constraintProperties on StatisticalVariable nodes, ensuring that other properties are treated as metadata and not incorrectly included in generated names or definitions. The feedback recommends improving the robustness of these changes by performing namespace-insensitive lookups when retrieving constraint properties and their values from the node's property-value map.
When a user defines a StatisticalVariable with an explicit constraintProperties list alongside extra metadata properties: Node: MyVariable typeOf: dcid:StatisticalVariable myConstraintProperty: value1 myNonConstraintProperty: value2 constraintProperties: myConstraintProperty ingestion previously ignored the explicitly set "constraintProperties: myConstraintProperty" and overwrote it with every property on the node outside the hardcoded exclusion list: Node: MyVariable typeOf: dcid:StatisticalVariable myConstraintProperty: value1 myNonConstraintProperty: value2 constraintProperties: myConstraintProperty, myNonConstraintProperty As a result, any custom metadata on a StatVar (such as sourceIndicatorCode: "NGDP") was treated as a constraint property and included in the auto-generated name and definition. This change respects constraintProperties when explicitly set by the user: - Keep the declared constraintProperties list as-is instead of overwriting it. - Only derive constraintProperties when none is declared on the node. - Use only the declared constraint properties when generating fallback name and definition values. - Log a warning (Mutator_MissingConstraintPropertyValue) if a declared constraint property has no value on the node.
dwnoble
force-pushed
the
respect-declared-constraint-properties
branch
from
October 14, 2026 22:32
b942a21 to
172482d
Compare
ajaits
reviewed
Oct 15, 2026
ajaits
reviewed
Oct 15, 2026
ajaits
reviewed
Oct 15, 2026
ajaits
reviewed
Oct 15, 2026
ajaits
reviewed
Oct 15, 2026
ajaits
approved these changes
Oct 15, 2026
dwnoble
force-pushed
the
respect-declared-constraint-properties
branch
from
October 15, 2026 23:39
9208ca7 to
bd465bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user defines a
StatisticalVariablewith an explicitconstraintPropertieslist alongside extra metadata properties:ingestion previously ignored the explicitly set
constraintProperties: myConstraintPropertyand overwrote it with every property on the node outside the hardcoded exclusion list:As a result, any custom metadata on a StatVar (such as
sourceIndicatorCode: "NGDP") was treated as a constraint property and included in the auto-generatednameanddefinition.Solution
Respect
constraintPropertieswhen it is explicitly set by the user, and only derive the list when none is declared on the node.Technical Details
McfMutator.mutateNode:constraintPropertieslist.dcid:,dcs:,schema:), de-duplicates the declared property names, skips any property inVocabulary.NON_CONSTRAINT_STAT_VAR_PROPERTIES(loggingMutator_InvalidConstraintProperty) or missing a value on the node (loggingMutator_MissingConstraintPropertyValue), and writes the validatedconstraintPropertiesback to the node.constraintPropertiesfrom all properties outsideVocabulary.NON_CONSTRAINT_STAT_VAR_PROPERTIES.constraintPvsfor both the Base DCdefinitionand fallbackname.McfMutatorcallers: Platform Spanner ingestion (GraphTransformer), thedc-importCLI (tool/Processor), andserver/Processor.StatVarNameGenerator:generateName(PropertyValues pvs, Set<String> constraintProps)soMcfMutatorcan pass the resolved constraint property set when generating fallback StatVar names.generateName(PropertyValues pvs)path to also respectconstraintPropertieswhen present onpvsbefore falling back toVocabulary.NON_CONSTRAINT_STAT_VAR_PROPERTIES.Testing
McfMutatorTest: Added unit tests covering:constraintPropertiesalongside extra metadata (sourceIndicatorCode: "NGDP")constraintPropertiesfalling back to derivationdcs:,schema:)constraintProperties, excluded fromname/definition)populationType,measuredProperty) filtered fromconstraintPropertieswhile still preserved as core properties in the generatednameanddefinitionconstraintProperties(both in MCF input and protoTypedValues)constraintPropertiesfalling back to derivationComplexValueexpansion ([dcs:Year 18]) with declaredconstraintPropertiesnameanddefinitionpreserved alongside declaredconstraintPropertiesStatVarNameGeneratorTest: Added tests for explicit, empty, andnullconstraint sets, plus 1-arggenerateName(pvs)whenconstraintPropertiesis present on the node.GraphTransformerTest: UpdatedtestStatVarTransformationWithExistingConstraintProperties(which previously pinned the overwrite behavior) and addedtestStatVarTransformationPreservesDeclaredConstraintPropertiesWithMetadata.