Skip to main content

Module codec

Module codec 

Source
Expand description

The COPY FROM STDIN formats.

CopyFormat is the closed, explicit set of supported formats — a small enum over the real implementations rather than a generic format framework. Each variant carries its validated options and its rules are stated where they apply: a variant’s match arms in the copy lifecycle (see the parent module) decide whether a target table is required, how the CopyData bytes are consumed, and which existing ingestion pipeline completes the copy. Adding a format is a normal extension: a new variant plus its arms.

§Parsing and conversion

Table-bound formats parse incrementally through a RecordParser: it consumes raw CopyData bytes and emits complete, insertable rows — one ParsedRow per record, in the order of the targeted columns. csv delegates splitting and typed conversion to arrow-csv’s incremental decoder (the engine behind COPY ... FROM 'file.csv') and turns decoded batches into rows with the shared api::helper::vectors_to_rows.

Formats that delegate to an existing ingestion pipeline (the influxdb line protocol) do not parse here at all: the whole payload is buffered as one bounded request body and completed through that pipeline, so record boundaries and values stay with the pipeline’s own parser.

§Options

The WITH (...) clause is open: every KEY value entry the client writes is collected into a [CopyOptionSet] (see options) regardless of whether any format understands it — the statement is parsed textually (see parse) precisely so options beyond sqlparser’s COPY grammar can reach the formats. A format builder takes the options it understands (take_string, take_single_byte, take_flag, or raw take_value for format-specific shapes) and rejects the rest with reject_leftovers.

Enums§

CopyFormat 🔒
A resolved COPY FROM STDIN format with its validated options.

Traits§

RecordParser 🔒
Incremental parser of one COPY FROM STDIN stream.

Type Aliases§

ParsedRow 🔒
A parsed, insertable row: one gRPC value per targeted column, in COPY field order. Every parser emits these directly, whatever mechanism it used to produce them.