Repository navigation
feat(schema-compiler): scaffolding emits drill_members so generated models can drill - #11472
igorlukanin wants to merge 7 commits into
Conversation
|
Claude finished @igorlukanin's task in 4m 22s —— View job Reviewed — no blockers. 1 medium, 3 low (all inline)Full review
SummarySolid, well-reasoned change. The rationale for deriving the set in the formatter rather than in The strongest thing here is the new test file: generating a model, running it through Dedupe-before-cap is subtle and correct to have handled, and the Findings
Other areas checked, no findings
Not verifiedI couldn't run the test suite — |
|
Claude finished @igorlukanin's task in 2m 37s —— View job Re-reviewed after
|
| # | Severity | Where | Issue | Status |
|---|---|---|---|---|
| new | Low | scaffolding-template.test.ts:589-594 |
The rewritten composite-key test now asserts [k6, k5, k4, k3, k2, k1, …], pinning an order the comment itself declines to vouch for. It comes from the inconsistent comparator sort((a) => a.isPrimaryKey ? -1 : 0) — implementation-defined, not a contract. Suggested an order-insensitive assertion inline. |
New inline comment |
| 1 | Medium | BaseSchemaFormatter.ts:171-173 |
"Already sorted by ScaffoldingSchema" still only holds on the table-name path; the cube-descriptor path passes dimensions through in caller order, so deleted_at can take the timestamp slot. Untouched by this commit. |
Prior thread, still applies |
| 2 | Low | BaseSchemaFormatter.ts:183-194 |
Dedupe keeps the first colliding dimension; the rendering it mirrors keeps the last, so classification can read the discarded definition. Untouched. | Prior thread, still applies |
| 3 | Low | YamlSchemaFormatter.ts:60 |
Dropping the trailing newline also hits empty joins: [], so it now spaces differently from non-empty joins:. Cosmetic. Untouched. |
Prior thread, still applies |
Resolved my own now-moot thread about the composite-key cap trading away both the timestamp and key integrity — the cap it was about no longer exists.
Also worth a note, not a finding
With the cap gone, a genuinely wide table (many dictionary-matching columns, or a description column) can render a long inline drill_members: [...] line. Valid YAML/JS, and arguably the correct trade against silent truncation — flagging only so the line-length consequence is a known one rather than a surprise.
Areas checked, nothing new
- Security — unchanged surface;
memberName()still collapses everything outside[A-Za-z0-9]before emitting, so member names can't inject YAML/JS syntax. - Performance — removing the slices makes the pass marginally cheaper;
drillMembersPropis still computed once per cube, not per measure. - Error handling — the empty-list path (key omitted entirely) is still covered and tested; nothing throws on a dimension list with no key and no timestamp.
- Testing —
scaffolding-drill-members.test.tsis unchanged and still the strongest assertion here: it compiles each of the three emitted variants with the real compiler and checks every drill member resolves to a dimension ofcube.config, plus that the aggregate measure andcountagree. That's what makes the cap removal safe to take on faith. - Docs — internal scaffolding behaviour, no user-facing surface.
Not verified
Couldn't run the suite — node_modules isn't installed in this checkout and yarn/jest need approval here, so the green-suite claim rests on your run. Findings come from reading the code, the rewritten tests, and the snapshots.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11472 +/- ##
==========================================
+ Coverage 63.63% 63.88% +0.25%
==========================================
Files 248 248
Lines 20051 20081 +30
Branches 4099 4108 +9
==========================================
+ Hits 12759 12829 +70
+ Misses 6701 6662 -39
+ Partials 591 590 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Claude finished @igorlukanin's task in 3m 17s —— View job Re-reviewed after
|
| # | Severity | Where | Issue | Status |
|---|---|---|---|---|
| 4 | Low | YamlSchemaFormatter.ts:60 |
Dropping the trailing newline also hits the empty-joins case, so joins: [] and non-empty joins: now space differently. Cosmetic; still visible in the snapshot (lines 477, 514, 621, 658). |
Prior thread, still applies |
Resolved my three now-moot threads (main-time-dimension ordering, first-wins dedupe, pinned composite-key order). Left @igorlukanin's thread alone — that's the reviewer's to close.
Consequences worth knowing about, not findings
Both follow directly from the decision the commit makes deliberately, and neither is fixable without reintroducing name-based guessing — flagging so they're known rather than discovered later:
- Sensitive columns drill by default. The regenerated snapshot has
drill_members: [id, username, password]. The column was already emitted as a dimension, so nothing is newly exposed in the model — but it does become part of the default drill-down result set, where before the dictionary happened to exclude it. Detecting it would mean reading the column name, which is exactly what this commit removes, so the honest answer is that it's the user's edit to make on generated output. - Unbounded inline arrays. With both the cap and the dictionary gone, a wide table renders every dimension on one
drill_members: [...]line. Valid YAML and JS; just a long line.
Areas checked, nothing new
- Security — unchanged surface;
memberName()still collapses everything outside[A-Za-z0-9]to_before emitting, so member names can't inject YAML/JS syntax. Member names that aren't valid bare JS identifiers would break the generated file, but thedimensionsblock already emits unquoted keys, so that constraint is pre-existing and not widened here. - Performance — one filter pass more than before over a small list;
drillMembersPropstill computed once per cube, not per measure. - Error handling —
d.type ?? d.types?.[0]covers both descriptor shapes; a dimension with neither classifies as a non-time attribute rather than throwing. Empty dimension list still omits the key entirely, still tested. - Testing — the added tests are the strongest part: deliberately opaque column names (
zzz_top,qux,blorb) so selection can't pass by recognising anything, and thejsonb/bytea/text[]case documenting thatcolumnTypecalls everything non-numeric/boolean/time a string.scaffolding-drill-members.test.tsis unchanged and still compiles all three variants with the real compiler. - Docs — internal scaffolding behaviour, no user-facing surface.
Not verified
node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code, the tests, and the regenerated snapshots (which are internally consistent with the diff).
|
Claude finished @igorlukanin's task in 2m 15s —— View job Re-reviewed after
|
| # | Severity | Where | Issue |
|---|---|---|---|
| 5 | Low | YamlSchemaFormatter.ts:60 |
Binding this in the inline-array branch also made a second latent case live: elements are rendered with no parent, so a scalar element takes the Array.isArray(parent) ? '' : ' ' branch at line 111 and comes back with a leading space — key: [ a, b]. Not visible today (drill members are all MemberReferences, which return early), but reachable from an array-valued schemaContext prop, which previously threw instead. Suggested passing the array as parent inline. |
Test-precision note, not a finding
The new test's expect(content).toMatch(/\n\s+joins: \[\]\n\n\s+dimensions:/) uses \s+ for the indent, which also matches newlines — so it would still pass if the separator regressed to two blank lines, the exact failure mode the commit is about. /\n\s+joins: \[\]\n\n {4}dimensions:/ pins it. The snapshots catch it either way, so this is belt-and-braces.
Prior findings
All four are now resolved — the three from earlier passes were closed by 45d4ae1, and #4 (the empty-joins spacing) by this commit. No unresolved threads of mine remain on the branch; @igorlukanin's thread is theirs to close.
Areas checked, nothing new
- Security — unchanged surface. The new code touches whitespace only;
memberName()still collapses everything outside[A-Za-z0-9]before emitting, so member names can't inject YAML syntax. - Performance —
Object.entrieswas already being computed on this path; hoisting it into a local means it's computed once instead of once, no change. - Error handling —
value[key] || {}still guards the null case, now before the.maprather than inside it. - Testing — the drill-member coverage is unchanged from the last pass and still the strongest part:
scaffolding-drill-members.test.tscompiles all three emitted variants with the real compiler and asserts every drill member resolves to a dimension ofcube.config. - Docs — internal scaffolding behaviour, no user-facing surface.
Not verified
node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code and the snapshots, which are internally consistent with the diff.
|
Claude finished @igorlukanin's task in 1m 21s —— View job Re-reviewed after
|
| # | Severity | Where | Issue |
|---|---|---|---|
| 6 | Low | YamlSchemaFormatter.ts:64 |
This branch emits a YAML flow sequence, but escapedValue quotes only on /[{}"]/ — so an element containing , or ] is emitted unquoted and splits the sequence (['a, b', 'c'] → three items). Same reachability as the padding case just fixed, and the same regression shape: it used to throw before the this binding, now it produces wrong output. Inline, with a suggested direction. |
Prior findings
All six earlier threads are resolved — the three from the first pass by 45d4ae1, the empty-joins spacing by 8512125, the pinned composite-key order by 45d4ae1, and the element padding by this commit. @igorlukanin's thread is theirs to close.
Areas checked, nothing new
- Security — unchanged surface.
memberName()still collapses everything outside[A-Za-z0-9]before emitting, so member names can't inject YAML syntax; finding ResultSet.normalizePivotConfig() fix #6 is about caller-supplied context values, not member names. - Performance — one extra argument per element; nothing measurable.
- Error handling — the array branch has no throwing path left on scalars;
ValueWithCommentsand nested objects are excluded by theeveryguard above. - Testing — drill-member coverage is unchanged from the last pass and still the strongest part:
scaffolding-drill-members.test.tscompiles all three emitted variants with the real compiler and asserts every drill member resolves to a dimension ofcube.config. The three YAML-formatter tests added across the last two commits (emptyjoinsspacing, element padding, drill set == dimension set) each pin a distinct invariant of the shared inline-array branch, which is what makes changes there safe to make. - Docs — internal scaffolding behaviour, no user-facing surface.
Not verified
node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code, the new test, and the snapshots (unchanged by this commit, correctly).
|
Claude finished @igorlukanin's task in 1m 31s —— View job Re-reviewed after
|
| # | Severity | Where | Issue |
|---|---|---|---|
| 7 | Low | YamlSchemaFormatter.ts:133 |
needsQuotes covers "ends an item" but not : (turns the element into a single-pair flow mapping, [a: b] → [{a: b}]) or # (starts a comment). Pre-existing in the block path too and strictly less bad than the comma case this fixes, so flagged as a note on the line that now owns the decision. Inline. |
Prior threads
All seven earlier threads are resolved — nothing of mine is still open on the branch. Nothing to re-affirm.
Areas checked, nothing new
- Security — unchanged surface. The widening only ever adds quoting, never removes it, so no previously-escaped value becomes bare.
memberName()still collapses everything outside[A-Za-z0-9], so drill member names remain unable to carry YAML syntax; this whole branch is about caller-supplied context values. - Performance — one boolean argument and a regex chosen by a ternary per scalar element. Nothing measurable.
- Error handling — no new throwing path; the non-string early return still short-circuits before either regex.
- Testing — the YAML branch now has four tests pinning four distinct invariants (empty-
joinsseparator, element padding, flow escaping, drill set == dimension set), which is what makes this shared branch safe to keep editing.scaffolding-drill-members.test.tsis unchanged and still the strongest assertion in the PR: it compiles all three emitted variants with the real compiler and checks every drill member resolves to a dimension ofcube.config. - Docs — internal scaffolding behaviour, no user-facing surface.
Not verified
node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code, the new test, and the snapshots (unchanged by this commit, correctly).
3d6ecad to
845ad08
Compare
|
Claude finished @igorlukanin's task in 1m 5s —— View job Re-reviewed after
|
| # | Severity | Where | Issue | Status |
|---|---|---|---|---|
| 7 | Low | YamlSchemaFormatter.ts:133 |
The flow escape set covers "ends an item" (, ]) but not : (turns the element into a single-pair flow mapping, [a: b] → [{a: b}]) or # (starts a comment). Pre-existing in the block path too, and strictly less bad than the comma case this branch fixes. |
Prior thread, still applies |
No prior thread of mine has become stale as a result of this push — the six earlier ones were already resolved, and #7's line still exists at the same place with the same code, so there's nothing to resolve and nothing to re-post.
Areas checked, nothing new
- Security — unchanged surface.
memberName()still collapses everything outside[A-Za-z0-9]before emitting, so drill member names can't carry YAML or JS syntax; the flow-quoting question is about caller-supplied context values, not member names. - Performance — unchanged.
- Error handling — unchanged:
d.type ?? d.types?.[0]covers both descriptor shapes, an empty dimension list omits the key,escapedValue's non-string early return still short-circuits before either regex. - Testing — unchanged from the last pass; the YAML branch has four tests pinning four distinct invariants, plus the real-compiler drill-member test.
- Docs — internal scaffolding behaviour, no user-facing surface.
Not verified
node_modules isn't installed in this checkout (confirmed: packages/cubejs-schema-compiler/node_modules absent) and yarn/jest need approval here, so I could not run the suite on the rebased head. The green-suite claim rests on your run. Since the trees are identical to the previously reviewed ones and master didn't touch this package, a rebase-induced test failure would have to come from elsewhere in master — worth letting CI confirm rather than taking from me.
845ad08 to
aca6b3d
Compare
|
Claude finished @igorlukanin's task in 1m 6s —— View job Re-reviewed after
|
aca6b3d to
48c1740
Compare
|
Claude finished @igorlukanin's task in 57s —— View job Re-reviewed after
|
…ets stay complete
…ot name-matched ones
…ll_members by warehouse type
48c1740 to
8d79c19
Compare
|
Claude finished @igorlukanin's task in 2m 37s —— View job No correctness bugs found. 1 medium issue (the PR description is out of date), 4 low (comments). Tests were not run: dependencies aren't installed and this job isn't allowed to run Review details
MediumThe PR description no longer matches the code. The body says The body also argues that dropping a JSON column "is the same class of guess as reading its name". That argument needs a rewrite, not just a flip. The new filter reads the warehouse type, not the column name, so it falls outside the objection from the first review. The body should say why that difference matters. It will feed the squash commit body. Checked, no issue
Low (inline)
Review threadsThe listing returned 0 of my own threads. I resolved none and re-affirmed none. |
| /** | ||
| * The members that identify one source row: every dimension the cube defines, with the | ||
| * primary key first and the time dimensions last. | ||
| * | ||
| * Every dimension, except non-scalar ones. Which columns are meaningful to drill into | ||
| * is not recoverable from a warehouse schema — the generator would have to guess from | ||
| * column names, and a name is not evidence of meaning. So the set is narrowed only by | ||
| * the raw column type: a JSON document, an array, binary data or a geometry doesn't | ||
| * read as a value in a drill-down table. The primary key stays whatever its type, | ||
| * since it is what identifies the row. Ordering is the only other judgement, and it | ||
| * costs nothing to be wrong about — key first because it identifies the row, time last | ||
| * because it reads as "when". | ||
| * | ||
| * Derived from the dimensions actually being rendered rather than from the ones | ||
| * ScaffoldingSchema computed: the cube-descriptor path lets the caller drop members, | ||
| * and a drill member the cube doesn't define dead-ends at click time. | ||
| */ |
There was a problem hiding this comment.
This JSDoc runs to 16 lines. Most of it argues the design ("not recoverable from a warehouse schema", "costs nothing to be wrong about"), and that argument belongs in the PR or commit message. Two sentences would stop a later edit from breaking something:
/**
* Every rendered dimension except non-scalar-typed ones (the primary key always stays), ordered key → rest → time.
* Derived from the dimensions being rendered: the descriptor path can drop members, and a drill member the cube doesn't define dead-ends at click time.
*/The ordering rule is already carried by primaryKeys / attributes / timeDimensions in the return statement.
| /** | ||
| * Dimensions are rendered into an object keyed by member name, so columns that | ||
| * collapse to the same name yield one dimension — the drill list must collapse too, | ||
| * or the drill-down repeats a column. | ||
| * | ||
| * Last-wins, matching the spread-reduce that renders `dimensions`: on a collision the | ||
| * cube keeps the later definition, so classifying off the earlier one would read | ||
| * `isPrimaryKey` / `isTime` from a definition the cube discarded. | ||
| */ |
There was a problem hiding this comment.
The first paragraph says the same thing as the // Deduped because… comment in drillMembers a few lines up. Only the last-wins sentence is needed here, because it is the one a later edit could break:
| /** | |
| * Dimensions are rendered into an object keyed by member name, so columns that | |
| * collapse to the same name yield one dimension — the drill list must collapse too, | |
| * or the drill-down repeats a column. | |
| * | |
| * Last-wins, matching the spread-reduce that renders `dimensions`: on a collision the | |
| * cube keeps the later definition, so classifying off the earlier one would read | |
| * `isPrimaryKey` / `isTime` from a definition the cube discarded. | |
| */ | |
| /** Last-wins, like the spread-reduce that renders `dimensions` — the cube keeps the later definition on a name collision. */ |
| // The caller separates keys itself — a newline here doubles the blank line. | ||
| // Pass the array as parent so scalar elements skip the leading-space branch | ||
| // that indents a value after its key, and `flow` so they quote on the | ||
| // characters that would otherwise end an item in a flow sequence. |
There was a problem hiding this comment.
This comment is four lines, one over the limit. The flow argument is already explained at escapedValue, so this site only needs the two facts the call itself doesn't show:
| // The caller separates keys itself — a newline here doubles the blank line. | |
| // Pass the array as parent so scalar elements skip the leading-space branch | |
| // that indents a value after its key, and `flow` so they quote on the | |
| // characters that would otherwise end an item in a flow sequence. | |
| // No trailing newline: the caller separates keys. `value` as parent skips the | |
| // leading space a scalar gets after its key; `flow` quotes item-ending chars. |
| expect(dimensionNames).toContain(member); | ||
| }); | ||
|
|
||
| // Primary key first, main time dimension last. |
There was a problem hiding this comment.
This comment is left over from the .slice(0, 1) version. There is no "main" time dimension any more, since a9e27f1 keeps all of them. The fixture has a single timestamp, so the assertion passes, but the comment describes a rule that no longer exists.
| // Primary key first, main time dimension last. | |
| // Primary key first, time dimensions last. |
Summary
Scaffolding declared
drillMembersonTableSchemaand never assigned it — the only reference to that field in the whole package. So data models generated from a warehouse schema came out with no drill members, and every measure in them was a dead end: clicking a chart point or a table cell couldn't open the underlying rows.This makes the scaffolding formatters emit
drill_memberson each measure, including the generatedcount.The drill set is every scalar dimension the cube defines
Ordered primary key first, then the rest, then the time dimensions. Nothing is capped, and nothing is filtered by name — only non-scalar columns are left out, by their warehouse type.
An earlier revision of this branch chose a few "describing" attributes by matching member names against a ten-word dictionary (
name,status,category, …). That was rejected in review, and rightly: which columns are meaningful to drill into isn't recoverable from a warehouse schema, and a column name is not evidence of meaning. Once name-based inference is off the table, no signal remains that separates a describing column from any other — cardinality and nullability are the same guess wearing a structural costume, and neither is available at generation time without extra warehouse queries.So the set isn't narrowed by meaning. The asymmetry settles it: a member you don't want is one you delete from generated output you were going to review anyway, whereas one that was never emitted is one you have to know to add.
Ordering is the only editorial judgement left, and a cheap one to get wrong — key first because it identifies the row, time last because it reads as "when".
Non-scalar columns are excluded by their raw warehouse type.
columnType()returnsstringfor anything it doesn't recognise as numeric, boolean or time, so JSON documents, arrays, maps and structs, binary data and geometries all become string dimensions. They stay dimensions of the cube, but they don't read as a value in a drill-down table, so they are left out ofdrill_members.isNonScalarColumnTypedecides from the type name the driver reports (jsonb,VARIANT,text[],ARRAY<STRING>,Map(String, UInt8),row(x varchar),bytea,geography,point, …) and never from the column name. Quoted literals are stripped first, so an enum such asEnum8('record' = 1)stays scalar. The primary key is always kept, whatever its type (abinary(16)UUID key still identifies the row).The raw type is read from the table definition in the formatter rather than carried on the member, because cube descriptors round-trip through the caller without it. Numeric columns still never reach the drill set, as
ScaffoldingSchema.dimensionColumnsroutes them to measures.Known limit: Postgres reports both PostGIS types and enums as
USER-DEFINED, so that type is treated as scalar and PostGIS columns stay in the drill set.All time dimensions are kept. Picking a single "main" timestamp would mean delegating the choice to
ScaffoldingSchema.timeColumnIndex, which ranks time columns by whether their names containcreateorupdate— reintroducing the rejected mechanism, and dropping every other timestamp on the strength of a two-word list. That sort still runs, socreated_atrenders beforedeleted_at, but it now affects display order only, never membership.The list is deduped by rendered member name, last-wins. Dimensions render into an object built with a spread-reduce, so on a collision the cube keeps the later definition. Deduping first-wins would classify the drill member (
isPrimaryKey/isTime) off the definition the cube discarded — auser_namevarchar followed by aUSER NAMEtimestamp would be filed as an attribute while the cube defines it as time.Why the formatter and not
ScaffoldingSchemaThe declared field is left unused and the set is derived where the model is rendered, for two reasons:
generateFilesByCubeDescriptorsspreads the caller's members over the generated descriptor, so the dimensions actually emitted can be a subset chosen elsewhere — the onboarding screen where members get deselected. A set computed upstream could name a dimension the cube no longer defines: the same click-time dead end, from the other direction.memberName()derives the emitted name from the title and re-cases it, soORDER_STATUSrenders asorderStatus/order_status. Only the formatter knows that name.Deriving there also gives the synthetic
countits drill set — it exists only as the formatter'sreduceseed and never appears intableSchema.measures, yet it's the measure most likely to be drilled.Note the descriptor path has no type filter at all, since
dimensionColumnsnever runs on caller-supplied members: a numeric dimension the caller sends does become a drill member. Deliberate and tested — the caller called it a dimension.The emitted form is a bare list, not a function
Worth recording because the validator misleads:
CubeValidator.tshasdrillMembers: Joi.func(), which reads as though the generator should emit a function wrapper. It shouldn't — the authored form is a bare bracket list of identifiers in JS and a plain list in YAML, andCubePropContextTranspilerwraps it into the function the validator sees.Tests
Scaffolding unit tests green (99 tests), lint clean.
The decisive test generates a model, compiles it with the real compiler, and asserts every drill member resolves to a dimension of the generated cube. Text assertions alone would happily pass on output that dead-ends at click time.
Every assertion was re-verified against deliberately wrong implementations: reinstating a lexical filter (13 tests red), first-wins dedupe (1), capping to one timestamp (5), time-before-attributes (9), dropping the primary-key guard on the time filter (1), removing the non-scalar filter (2), dropping the primary-key exemption from it (1), and not stripping quoted enum labels (3).
The snapshot churn is itself the evidence for the change — fixtures that previously emitted
drill_members: [id]now emit[id, username, password], and[id, test]becomes[id, test, customerkey]. Those columns were always dimensions of the generated cube; the dictionary was silently dropping them.Backward compatibility
Additive to generated output only. Scaffolding runs at generation time, so nothing already in a user's repo changes — the new key appears in newly generated cube files, which is the point.
One incidental fix:
YamlSchemaFormatter's inline-array branch dropped its trailing newline, which had been doubling the blank line after any array-valued key. The same expression also passed array indices intorenderas itslevel/parentarguments; now bound properly.