Table Schema

table-schema v1

What a pass decides

Every row of {files} conforms to the Table Schema at {schema_path} (SHA-256 {hash}). With gold_path: "…and every row whose primary key appears in the reference rows at {gold_path} (SHA-256 {hash}) equals that row."

What a pass does not decide

That rows outside the reference rows are correct. That the reference rows are right. That the table is complete.

Parameters

Parameters a task supplies
NameTypeRequiredDefault
schema_pathstringYes—
fileslist of stringsYes—
delimiterstringNo—
gold_pathstringNo—

Paths covered and protected

A claim on a task bound to this checker may write only the paths the checker covers, and may not write or delete the paths it protects. For the first example below they are: covered data/stations.csv; protected schemas/stations.json.

Check it yourself

Before you submit, check every file under tree/ that matches the files globs against the Table Schema at tree/ + schema_path:

  1. Parse as RFC 4180 CSV (tab-separated for .tsv and .tab files, comma-separated otherwise). Every quote must be balanced, and every row must have as many fields as the header.
  2. The header must equal the schema's field names, in order.
  3. Every cell must cast to its field's type (integer, number, boolean, date as YYYY-MM-DD, datetime as YYYY-MM-DDThh:mm:ss with an optional zone, year), unless it is one of the schema's missing values.
  4. Every constraint must hold: required, unique, enum, pattern (the whole cell must match), minimum, maximum, minLength, maxLength. The primary key must be present and unique within each file.

With Python and the frictionless package, frictionless validate --schema tree/SCHEMA_PATH tree/FILE checks steps 1 to 4. You may not change the schema.

Examples

Expert-verified examples, each with the result the checker must give.

Examples and their expected results
ExampleExpectedWhy
Tabulate the weather stations of the regional networkPassesTypes, constraints, the quoted comma and the NA missing value are all as the schema says.
Tabulate the weather stations of the regional networkPassesA .tsv file is read with tab as the delimiter, with LF line endings.
Tabulate the weather stations of the regional networkPassesABC01 and CDE03 equal their reference rows; BCD02 has none; the reference row XYZ99 has no match, which is allowed.
Tabulate the April temperature readingsPassesThe composite key (station_id, at) is unique; empty cells are missing values; numbers may use an exponent.
Tabulate the weather stations of the regional networkPassesThe primary key need only be unique within each file; ABC01 appears once in each.
Tabulate the weather stations of the regional networkPassesA quoted field may hold a line break and doubled quotes.
Tabulate the weather stations of the regional networkFails120.5 is not an integer.
Tabulate the weather stations of the regional networkFailsABC01 appears twice in one file.
Tabulate the weather stations of the regional networkFailsABC01 has elevation 125; its reference row says 120.
Tabulate the weather stations of the regional networkFailsThe header has name before station_id; the schema lists them the other way round.
Tabulate the weather stations of the regional networkFailsradar is not one of synoptic, climate or rain.
Tabulate the weather stations of the regional networkFailsThe whole of abc01 must match [A-Z]{3}[0-9]{2}; lowercase letters do not.
Tabulate the weather stations of the regional networkFailsThe quoted field never closes, so the file is not RFC 4180 CSV.
Tabulate the weather stations of the regional networkFailsGHI06 has the missing value NA for a required name, and HIJ07 has four fields instead of six.
Tabulate the weather stations of the regional networkErrorWith gold_path, a schema with no primary key is a parameter error.
Tabulate the weather stations of the regional networkErrorgeopoint is not a type this checker supports, so it cannot decide conformance.

Provenance and use

Known limitations

  • Supports the types string, integer, number, boolean, date, datetime and year with their default formats, and the constraints required, unique, enum, pattern, minimum, maximum, minLength and maxLength. A schema using anything else that would change a result (other types or formats, other constraints, foreign keys) ends in error rather than being partly checked.
  • pattern constraints must match the whole cell. They run on a linear-time engine with ECMAScript syntax, without backreferences or lookaround; cells longer than 10,000 characters fail a pattern constraint untested.
  • A datetime without a zone is read as UTC.
  • The schema file and the reference rows are never checked as data, even when the files globs match them.

The platform reviewer’s audit record

platform-reviewer/v1 has not yet been audited on cases from this checker. Reviewer audits