Skip to content

feat(metadata): recursively unnest data inside extracted array elements#86

Merged
jodeleeuw merged 1 commit into
mainfrom
feat/recurse-array-element-unnesting
Jun 9, 2026
Merged

feat(metadata): recursively unnest data inside extracted array elements#86
jodeleeuw merged 1 commit into
mainfrom
feat/recurse-array-element-unnesting

Conversation

@Mandyx22

@Mandyx22 Mandyx22 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Stacked on #84 (base = fix/array-element-fields-variablemeasured; will retarget to main once #84 merges).

Problem

Array-of-objects columns were extracted only one level deep, so an element field that was itself an object (validation_data.pointData.point) or an array (validation_data.pointData.gazeSamples) stayed an opaque JSON column.

Fix

accumulateArrayColumn now recurses via expandElementFields:

  • object inside an element → expanded into deeper dotted columns in the same sidecar row (pointData.point.x, pointData.point.y).
  • array inside an element → extracted into its own grandchild CSV, joinable to its specific parent element via a qualified <column>.element_index key carried alongside the existing join keys (e.g. trial_index + validation_data.pointData.element_index + the grandchild's own element_index).
  • Every key/column (including the qualified parent-index keys) is registered in variableMeasured; scalars keep type + min/max/levels tracking. Composes to arbitrary depth.

Verification

  • New tests incl. object-in-element, array-in-element (grandchild + multi-level join key), 3-levels-deep, and validation invariant across parent + grandchild tables. Full suite 206/206.
  • Real CLI binary on the full eye-tracking dataset (38 files): produces ...GazeSamples grandchild tables and validates with 0 errors; event-boundary still 0 errors.

Out of scope (separate follow-up)

Arrays of primitives (block_order:[16,100,4,1], images:[…]) are still recorded as a single value:"array" column with no per-element breakdown (issue #72 §3). Handled next, on its own branch.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 395e7f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@jspsych/metadata Minor
@jspsych/metadata-cli Minor
frontend Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jodeleeuw jodeleeuw deleted the branch main June 9, 2026 21:01
@jodeleeuw jodeleeuw closed this Jun 9, 2026
@jodeleeuw jodeleeuw reopened this Jun 9, 2026
@jodeleeuw jodeleeuw changed the base branch from fix/array-element-fields-variablemeasured to main June 9, 2026 21:05
Array-of-objects columns were extracted only one level deep, so an element field
that was itself an object (pointData.point) or an array (pointData.gazeSamples)
was kept as a single opaque JSON column.

accumulateArrayColumn now recurses (expandElementFields): a nested plain object is
expanded into deeper dotted columns in the same sidecar row (pointData.point.x);
a nested array-of-objects is extracted into its own grandchild CSV, joinable to its
specific parent element via a qualified `<column>.element_index` key carried with
the existing join keys. Every key/column is registered in variableMeasured.

Verified with psychds-validator: full eye-tracking dataset (38 files) via the real
CLI binary produces grandchild gazeSamples tables and validates with 0 errors;
event-boundary still 0 errors. Full suite 206/206.

Note: arrays of primitives are still recorded as a single value:"array" column
(no per-element breakdown) — tracked as a separate follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jodeleeuw jodeleeuw force-pushed the feat/recurse-array-element-unnesting branch from afc4db8 to 395e7f7 Compare June 9, 2026 21:06
@jodeleeuw jodeleeuw merged commit d9e4485 into main Jun 9, 2026
2 checks passed
@jodeleeuw jodeleeuw deleted the feat/recurse-array-element-unnesting branch June 9, 2026 21:06
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