Documentation
¶
Overview ¶
Package cell defines the typed-cell substrate shared by all XQL backends. A Table is a rectangular grid of Cells under a fixed schema; backends (CSV today, SharePoint tomorrow) hydrate into this shape so the expression evaluator and predicate matcher can run uniformly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare(a, b Cell, t ColumnType) int
Compare returns -1, 0, or +1 for the natural ordering of two Cells under the given column type. NULL sorts low. Used by predicate evaluation and ORDER BY.
func FormatCell ¶
func FormatCell(v Cell, t ColumnType) string
FormatCell renders a typed Cell back to a text field string. NULL becomes the empty string. Dates that have no time component render as date-only; the rest use RFC 3339. Floats use the shortest round-trippable form.
func ParseDateString ¶
ParseDateString tries the ISO 8601 forms XQL supports. Anything outside these formats falls through to string, intentionally; predictable beats aggressive guessing.
func RenderLiteral ¶
RenderLiteral returns the XQL surface form of a parsed literal, used in error messages so coercion failures echo the user's input back to them.
Types ¶
type Cell ¶
Cell is a typed value. Exactly one of the Str/Int/Float/Bool/Date fields is meaningful, picked by the column's ColumnType. An empty source cell becomes a Cell with Null = true regardless of the column type.
func CoerceLiteral ¶
func CoerceLiteral(lit parse.Value, t ColumnType) (Cell, error)
CoerceLiteral converts a parsed XQL literal (parse.Value) to a Cell compatible with the given ColumnType. Used by INSERT and UPDATE to coerce user-supplied literals at write time. Returns an error if the literal cannot meaningfully coerce (for example 'abc' into an int column).
func ParseCell ¶
func ParseCell(raw string, t ColumnType) Cell
ParseCell converts a raw text cell to a typed Cell using the column's inferred type. An unparseable cell becomes NULL rather than failing the load; pin the column to string via --type if you prefer the raw text.
func (Cell) AsAny ¶
func (v Cell) AsAny(t ColumnType) any
AsAny returns the Cell as an untyped Go value suitable for JSON encoding. NULL becomes nil; everything else returns the underlying typed value.
func (Cell) Render ¶
func (v Cell) Render(t ColumnType) string
Render returns the human-readable form of a Cell for table/TSV output. NULL renders as the empty string.
type ColumnInfo ¶
type ColumnInfo struct {
Name string
Type ColumnType
}
ColumnInfo describes one column in a Table.
type ColumnType ¶
type ColumnType int
const ( TypeString ColumnType = iota TypeInt TypeFloat TypeBool TypeDate )
func ParseColumnType ¶
func ParseColumnType(s string) (ColumnType, error)
ParseColumnType maps a --type=... flag value back to a ColumnType.
func (ColumnType) String ¶
func (t ColumnType) String() string
type Table ¶
type Table struct {
Path string
Columns []string
Schema map[string]ColumnInfo
Rows []Row
Delim rune
HasHeader bool
}
Table is the in-memory representation of one bound dataset (CSV, SP list, etc.). Columns preserves header order; Schema maps name to type info; Rows holds the typed records. Backend-specific dialect fields (CSV's Delim/HasHeader, SP's site/list URL) hang off the Table — fields not understood by a given backend are zero-valued and ignored.