Skip to content

fix(CEMAS-103): stop leading comma when a dimension fails to resolve - #308

Merged
johnson-abraham merged 5 commits into
mainfrom
fix/CEMAS-103-fdl-leading-comma-on-unresolved-dimension
Sep 23, 2026
Merged

johnson-abraham merged 5 commits into
mainfrom
fix/CEMAS-103-fdl-leading-comma-on-unresolved-dimension

Conversation

@johnson-abraham

@johnson-abraham johnson-abraham commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • addDimensionToSQLProjection gated the , separator on loop index (i > 0) rather than on whether a dimension was actually emitted. When an earlier dimension in the list isn't registered in tableSchemas (e.g. a hidden/stale field pulled in transitively by an upstream caller) and gets skipped via continue, the next resolvable dimension still received a leading comma before it — producing SELECT, <col>, ... and a DuckDB Parser Error: syntax error at or near ",".
  • Fixed by tracking whether any dimension has actually been emitted and gating the comma on that instead of the loop index.
  • This mirrors an equivalent, real production incident traced in devrev-web (a widget list-view field-dependency resolver was including a ui.isHidden field in the FDL dimensions array; that field is legitimately absent from meerkat's tableSchemas because the schema builder filters hidden fields). This fix makes applyProjectionToSQLQuery resilient to that mismatch regardless of which caller produces it.

DevRev

work-item: CEMAS-103

Test plan

  • Added a regression test (should not emit a leading comma when an earlier dimension fails to resolve) that fails on the pre-fix code and passes with the fix.
  • Full meerkat-core test suite passes (564 passed, 11 pre-existing skips, 0 failures).
  • nx lint meerkat-core — 0 errors (36 pre-existing warnings, none in touched files).

Before fix:

Screen.Recording.2026-09-19.at.1.34.35.PM.mov

After fix:

Screen.Recording.2026-09-19.at.1.35.43.PM.mov

addDimensionToSQLProjection gated the separator on loop index, so a
dimension that isn't registered in tableSchemas (e.g. a hidden or
stale field pulled in by an upstream caller) got skipped via continue
but still left the next resolvable dimension with a leading comma,
breaking the generated SQL with a DuckDB parser error. Gate on whether
a dimension was actually emitted instead.

work-item: CEMAS-103
Comment thread meerkat-core/src/cube-measure-transformer/cube-measure-transformer.ts Outdated

@zaidjan-devrev zaidjan-devrev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please bump the package.json versions too

Address review feedback:
- Bump meerkat-core, meerkat-browser, meerkat-node to 0.0.136.
- Clarify why a dimension can go unemitted: `dimensions` is
  caller-supplied and not guaranteed to match `tableSchemas` (e.g. a
  caller passing a field deliberately excluded from the schema).

work-item: CEMAS-103
@johnson-abraham

Copy link
Copy Markdown
Contributor Author

Bumped meerkat-core, meerkat-browser, and meerkat-node to 0.0.136 (matching the convention in prior PRs of bumping all three together, e.g. #299).

…p state

Per review feedback: build an array of resolved entries and join them
with the separator, rather than tracking loop index / an emitted-flag
to decide when to prepend a comma. Removes the need to reason about
what happened in a previous iteration, and applies the same pattern to
cubeMeasureToSQLSelectString for consistency.

work-item: CEMAS-103
The prior commit's comment trim removed three comments that predate
this change and document unrelated behavior:
- the source-table resolution note above dimensionSchema lookup
- the safeKey replacement note above the forEach
- the alias-key note above the dimension push

Restore all three.

work-item: CEMAS-103
Comment thread meerkat-core/src/cube-measure-transformer/cube-measure-transformer.ts Outdated
…ring

Per review feedback: cubeMeasureToSQLSelectString was never part of
the reported bug and shouldn't be structurally changed in this PR.
Restored it to its original loop-based form, byte-identical to main.
addDimensionToSQLProjection keeps the collect-and-join fix, which is
what the regression test covers.

work-item: CEMAS-103
@johnson-abraham
johnson-abraham merged commit ab88ae9 into main Sep 23, 2026
4 checks passed
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.

2 participants