}bedrock.hier.clone – N→C Element Conversion, Extended Attribute Handling & Subset/MDX Filter Support#446
Open
PPN-OL wants to merge 2 commits into
Open
}bedrock.hier.clone – N→C Element Conversion, Extended Attribute Handling & Subset/MDX Filter Support#446PPN-OL wants to merge 2 commits into
PPN-OL wants to merge 2 commits into
Conversation
…ling & Subset/MDX Filter Support
…ling & Subset/MDX Filter Support
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.
Summary
This update extends
}bedrock.hier.clonewith three related enhancements:pIfNthanC): Numeric (N) elements can be automatically promoted to Consolidated (C) elements during cloning, preventing unintended leaf nodes and making the target hierarchy immediately ready for child assignments.pAttr = 2): Attribute values are copied only for attributes that already exist on both source and target, leaving a curated target attribute schema untouched.pSrcFilter): Only the elements resolved by a named subset or an MDX expression are cloned, enabling partial hierarchy copies.Motivation
When an existing dimension is used as the basis for a new, more detailed dimension, its leaf (N) elements must first be converted to consolidation (C) elements before children can be added. Previously this required a manual post-processing step. With
pIfNthanC = 1this conversion is now handled automatically inside the clone process itself.In addition, real-world cloning scenarios often require only a subset of elements to be copied — for example the children of a single consolidation, or elements matching a business filter. The new
pSrcFilterparameter enables this without requiring a separate pre-processing step.Changes
New Parameter:
pIfNthanC(Numeric, default: 0)01Extended
pAttrbehaviour – value2: copy only existing attributes012pAttr > 1,nNumAttrsis set fromsAttrTragetDim(target attr dim) instead ofsAttrDim(source attr dim), so the target's own attribute set drives the loop.pAttr >= 1(instead of= 1), and an additional guard skips copying when either the source or target attribute is not present andpAttr > 1.New Parameter:
pSrcFilter(String, default: '')''(empty)Subset:<name>pSrcDim:pSrcHierare clonedMDX:<expression>Prolog – variable initialisation:
Prolog – filter resolution block (inserted after the first error-check, before hierarchy creation):
Subset:/MDX:prefix; logs an error for any unrecognised prefix.Subset:mode: validates subset existence viaSubsetExists; aborts if not found.MDX:mode: calls}bedrock.hier.sub.create.bymdxwithpConvertToStatic=1andpTemp=1; stores the unique temp name from the existingcTempSubconstant.sTempSubset = 'ALL'whenpSrcFilteris empty.Prolog – element insertion loop — iteration source swapped from
DimSiz/ElementNametoSubsetGetSize/SubsetGetElementName; the existingpIfNthanCbranch is preserved unchanged:Prolog – datasource assignment updated from
'ALL'tosTempSubset, so the Metadata and Data tabs iterate only the filtered elements.Metadata tab —
SubsetGetIndexguard added beforeHierarchyElementComponentAddto prevent linking children that are outside the working subset (strict partial hierarchy):Data tab — no changes; iterates
vElefrom the datasource subset automatically.Epilog – cleanup (placed before the recursive self-call):
Epilog – recursive self-call extended with
'pSrcFilter', pSrcFilter.cLogInfoupdated to includepIfNthanCandpSrcFilterin the log output line.Files Changed
nTempSubsetCreated,sTempSubset,sFilterPrefix,sFilterValue)cLogInfoconstant extended to logpIfNthanCandpSrcFilterDimSiz/ElementNamereplaced bySubsetGetSize/SubsetGetElementName;pIfNthanCbranch preserved'ALL'replaced bysTempSubsetElseIf(pAttr > 1 ...)branch added to setnNumAttrsfrom target attr dimSubsetGetIndexguard added beforeHierarchyElementComponentAddpAttr = 1topAttr >= 1; skip-guard added forpAttr > 1pIfNthanCandpSrcFilteradded to recursiveExecuteProcesscallpIfNthanCandpSrcFilteradded;pAttrprompt updatedTesting
pIfNthanC = 0(default)pIfNthanC = 1, source has N-elementspIfNthanC = 1, source has S-elementspAttr = 1pAttr = 2pAttr = 2, target has no attributespIfNthanCandpSrcFiltercorrectlypSrcFilter = ''(default)sTempSubset = 'ALL'pSrcFilter = 'Subset:MySub', subset existsMySubare cloned; child links outside subset are omittedpSrcFilter = 'Subset:Missing', subset not foundpSrcFilter = 'MDX:{...}', valid MDXpSrcFilter = 'MDX:{...}', invalid MDX}bedrock.hier.sub.create.bymdxreturns error; process abortspSrcFilter = 'INVALID'(no prefix)pSrcFilter+pIfNthanC = 1Notes
pIfNthanCcondition intentionally excludes String (S) elements, as S-elements cannot be consolidated and must remain S.pAttr = 2is intended for scenarios where the target dimension has a curated, pre-defined attribute schema that must not be altered by the clone operation.pSrcFilterwithMDX:prefix requires}bedrock.hier.sub.create.bymdxto be available on the server. The temporary subset is always created as a public, static subset with a unique name derived fromcTempSub(process name + timestamp + random int) to prevent name collisions under concurrent execution.pSrcFilteris active and the subset resolves to zero elements, the target hierarchy is created or cleared but left empty — no error is raised.pSrcFilteris forwarded unchanged in the recursive Epilog call (new-dimension scenario). Each recursive invocation resolves the filter independently and manages its own temporary subset lifecycle.