Skip to main content

Module csv

Module csv 

Source
Expand description

The csv format — currently the only implemented COPY FROM STDIN format.

Parsing and typed conversion both reuse arrow-csv’s incremental Decoder — the same engine backing GreptimeDB’s file-based COPY ... FROM 'file.csv' (see common-datasource‘s csv file format) — so both COPY routes accept identical data. The decoder splits records (quoting, escaped quotes, custom delimiters, \n/\r\n separators, optional headers) and converts fields against the targeted columns’ schema in one pass.

Consequences of sharing the engine: JSON and Binary columns are rejected, timestamps must be date/time strings (offset-free ones parse in the session timezone), and an empty field — quoted or not — is NULL, exactly like file-based COPY.

Structs§

CsvCodec 🔒
The validated csv format configuration.
CsvRecordParser 🔒
Incremental parser backed by arrow-csv’s decoder.

Functions§

build_csv_codec 🔒
Builds the CSV codec from the parsed options.
decode_error 🔒
parse_pg_bool 🔒
Parses PostgreSQL’s boolean spellings: true/false, t/f, yes/no, on/off and 1/0, case-insensitive with surrounding whitespace allowed (see the BOOLEAN type’s input grammar). COPY OUT emits t/f, so accepting them keeps both COPY directions round-trippable.