home / skills / bdambrosio / cognitive_workbench / test-json-sql-pluck

test-json-sql-pluck skill

/src/saved_plans/test-json-sql-pluck

This skill extracts a single field from test data by plucking titles from papers and returning a titles collection.

npx playbooks add skill bdambrosio/cognitive_workbench --skill test-json-sql-pluck

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
416 B
---
name: test-json-sql-pluck
description: Tests pluck primitive (SELECT single field)
manual_only: true
---

# Test Pluck Primitive

**Self-contained:** Creates test data internally

**Input:** Creates $papers collection (4 papers with id, title, year, citations, venue)

**Operation:** Pluck title field from each paper

**Expected Output:** $titles collection with 4 items, each containing just the title string

Overview

This skill tests a pluck primitive that selects a single field from structured records. It creates a small, self-contained dataset of paper records and verifies that extracting the title field produces the expected collection of titles. The test is deterministic and requires no external data.

How this skill works

The test generates an internal $papers collection with four paper objects, each containing id, title, year, citations, and venue. It runs the pluck operation to select only the title field from every paper. The test asserts that the resulting $titles collection contains exactly four items and that each item is the title string from the corresponding paper.

When to use it

  • Validate a pluck/select-single-field implementation in a query engine or library.
  • Check that data pipelines correctly project a single primitive field out of objects.
  • Confirm behavior when mapping objects to primitive arrays for downstream consumers.
  • Regression testing after refactoring selection or projection code.
  • Teaching or demonstrating how a pluck operation transforms records to primitives.

Best practices

  • Keep test datasets small and explicit so failures are easy to inspect.
  • Include all relevant fields in source records even if only one is plucked, to catch unintended dependencies.
  • Assert both count and content to ensure correct ordering and completeness.
  • Run this test in isolation and as part of a broader test suite to catch integration regressions.
  • Document expected output clearly to make test intent obvious.

Example use cases

  • Unit test for a SQL-like pluck/select primitive that returns a single column as an array.
  • Verify JSON-to-CSV conversion where only the title column should be exported.
  • Check API endpoints that return only specific fields to minimize payload size.
  • Demonstrate to new contributors how projection operations should behave.
  • Quick sanity check after changes to the data model that might affect field names.

FAQ

Does the test depend on external resources?

No. The test creates its own $papers collection internally and does not use external data.

What exactly is asserted?

The test asserts that the $titles collection has four items and that each item is the title string from the corresponding paper.