# FEATURE: SQL-Style Builtins and Inventory

| Field | Value |
|-------|-------|
| Version | 20261028 V1 |
| Description | Provide SQL-style stream operations and the builtin function inventory. |
| Depends On | FEATURE-InputDiagnostics.md |
| Provides | jq SQL-style builtins and inventory |
| Consumes | jq input and diagnostic builtins |

## Purpose and behavior

The interpreter provides `INDEX(stream; index_expression)` and `INDEX(index_expression)`, producing an object keyed by the string conversion of each row's index expression. The one-argument form uses the input's elements as its stream.

`JOIN` supports the two-, three-, and four-argument forms described in the manual. It pairs each stream value with the indexed value at its computed key, using null for a missing key; the four-argument form applies the join expression to each pair. `IN` supports its one- and two-argument forms and tests stream membership using jq equality.

`builtins` emits an array of supported builtin names in `name/arity` form, with separate entries for distinct arities. Preserve argument evaluation, stream order, and short-circuit behavior defined by the manual and `sources/builtin.jq`.

## Programmatic Acceptance

=== AC sql-builtins-corpus ===
Intent: The SQL-style operators and builtin inventory pass their matching corpus programs.
Suite: scoped
Requires: executable=python3; scope=test
Probe: --list
Probe Count: summary

import json
import os
import subprocess
import sys

SELECT = r"\b(INDEX|JOIN|IN|builtins)\b"
result = subprocess.run(
    [sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"],
    capture_output=True,
    text=True,
    env={**os.environ, "JQ": os.path.abspath("jq")},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
report = json.loads(result.stdout)
tally = report["summary"]
print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored")
assert sum(tally.values()) > 0, f"selector matched no case: {SELECT}"
assert tally["fail"] == 0 and tally["error"] == 0, tally
assert result.returncode == 0, result.returncode
=== END AC sql-builtins-corpus ===

## User Acceptance

- None.

## Guardrails

- Use the Python standard library only; do not invoke or bind an external jq implementation.
- Keep staged source assets unchanged.
