cell

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 5 Imported by: 0

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

func ParseDateString(s string) (time.Time, error)

ParseDateString tries the ISO 8601 forms XQL supports. Anything outside these formats falls through to string, intentionally; predictable beats aggressive guessing.

func RenderLiteral

func RenderLiteral(lit parse.Value) string

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

type Cell struct {
	Null  bool
	Str   string
	Int   int64
	Float float64
	Bool  bool
	Date  time.Time
}

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 Row

type Row []Cell

Row is one record in the same column order as Table.Columns.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL