Vex · API

analyze

analyze checks a resolved query (the output of resolve) against the analyzer settings and returns { warnings, errors }. Example: the filter is on show_night, which has no index; with warnUnindexedFilters: true and rejectUnindexedFilters: false it is reported as a warning.

Query
{
  from: ['bookings', 'members'],
  fields: [
    { field: 'members.name', as: 'name' },
    { field: 'bookings.seats', as: 'seats' },
  ],
  filter: { eq: ['bookings.show_night', { $context: 'night' }] },
  sort: [{ field: 'members.name', dir: 'asc' }],
}
Table
CREATE TABLE bookings (
  id text PRIMARY KEY,
  show_night text NOT NULL REFERENCES shows(night),
  member_id text NOT NULL REFERENCES members(id),
  seats integer NOT NULL
)
Settings
{
  maxNestingDepth: 2,
  rejectCartesianProducts: true,
  warnUnindexedFilters: true,
  rejectUnindexedFilters: false,
}
Analysis result
{
  warnings: [
    'Unindexed filter columns: bookings.show_night. Consider adding indexes for better performance.',
  ],
  errors: [],
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.