SQL

Inspect equipment fields before accepting a record

BOTIE

Connect incoming equipment and the field contract to Check named field types. Inspect each record’s valid flag.
Ready to test
0 passed · 0 failed · 2 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Connect incoming equipment and the field contract to Check named field types. Inspect each record’s valid flag.

An import includes fields whose values do not fit the agreed equipment contract.

Inspect the component calculation
Check named field types(
  Incoming records: Incoming equipment
  Field contract: Expected value types
)
Examples and results
Incoming equipment
[
  {
    "id": "P7",
    "model": "M2",
    "cost_cents": 250
  },
  {
    "id": "P8",
    "model": "M3",
    "cost_cents": "unknown"
  }
]
Expected value types
{
  "id": "text",
  "model": "text",
  "cost_cents": "integer"
}
Required result
[
  {
    "id": "P7",
    "valid": true
  },
  {
    "id": "P8",
    "valid": false
  }
]
Incoming equipment
[
  {
    "id": "P2",
    "model": null,
    "cost_cents": 25
  }
]
Expected value types
{
  "id": "text",
  "model": "text",
  "cost_cents": "integer"
}
Required result
[
  {
    "id": "P2",
    "valid": false
  }
]
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

This checker validates decoded values. SQLite affinity and STRICT lossless conversions are taught in the SQL program, not simulated here. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.

A fractional cost arrived in the cents field

This check uses the pieces from “Check incoming equipment fields”.

BOTIE

The contract requires integer cents. P3 supplies 125.5 while P4 supplies 0. Predict which identity needs repair without changing the contract.
Incoming equipment
[
  {
    "id": "P3",
    "model": "M1",
    "cost_cents": 125.5
  },
  {
    "id": "P4",
    "model": "M2",
    "cost_cents": 0
  }
]
Expected value types
{
  "id": "text",
  "model": "text",
  "cost_cents": "integer"
}

Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

Why does an integer cost still need a documented unit and currency?

A schema records meaning as well as representation. The SQL table will enforce its declared domain rules.

This checker validates decoded values. SQLite affinity and STRICT lossless conversions are taught in the SQL program, not simulated here.

Work through the SQL challenges →
Continue the courseCan a Job Refer to a Pump We Have Never Recorded? →