Documentation
¶
Overview ¶
Arrow record batch flattener transforms complex types unsupported by Perspective (Struct, List, Map, Union) into simple columns. Structs are recursively flattened with dot-separated names; List, Map, and Union values are serialized to JSON strings.
Index ¶
- Variables
- func AsUser(ctx context.Context, userId, userName, role string) context.Context
- func ColumnValue(a arrow.Array, i int) any
- func ContextWithValidateOnly(ctx context.Context) context.Context
- func DataClose(data any)
- func ExtractResponseData(path string, data map[string]any) any
- func FlattenRecord(rec arrow.RecordBatch, mem memory.Allocator) arrow.RecordBatch
- func FlattenSchema(schema *arrow.Schema) *arrow.Schema
- func IsValidateOnlyContext(ctx context.Context) bool
- func NeedsFlatten(schema *arrow.Schema) bool
- func ParseJsonValue(v any) (map[string]interface{}, error)
- func RecordToJSON(rec arrow.RecordBatch, asArray bool, w io.Writer, ...) error
- func RecordsColNums(rr []arrow.RecordBatch) int64
- func RecordsRowNums(rr []arrow.RecordBatch) int64
- func RegisterGeometryDecoder(name string, fn GeometryDecoder)
- func ReleaseRecords(rr []arrow.RecordBatch)
- func RetainRecords(rr []arrow.RecordBatch)
- func Scan[T any](resp *Response, path string) (T, error)
- func WarpGraphQLError(err error) gqlerror.List
- type ArrowTable
- type ArrowTableChunked
- func (t *ArrowTableChunked) Append(rec arrow.RecordBatch)
- func (t *ArrowTableChunked) Chunk(i int) arrow.RecordBatch
- func (t *ArrowTableChunked) DecodeMsgpack(dec *msgpack.Decoder) error
- func (t *ArrowTableChunked) EncodeMsgpack(enc *msgpack.Encoder) error
- func (t *ArrowTableChunked) GeometryInfo() map[string]GeometryInfo
- func (t *ArrowTableChunked) Info() string
- func (t *ArrowTableChunked) MarshalJSON() ([]byte, error)
- func (t *ArrowTableChunked) NumChunks() int
- func (t *ArrowTableChunked) NumCols() int
- func (t *ArrowTableChunked) NumRows() int
- func (t *ArrowTableChunked) Reader(retain bool) (array.RecordReader, error)
- func (t *ArrowTableChunked) Records() ([]arrow.RecordBatch, error)
- func (t *ArrowTableChunked) Release()
- func (t *ArrowTableChunked) Retain()
- func (t *ArrowTableChunked) RowData(i int) (map[string]any, bool)
- func (t *ArrowTableChunked) Rows() (Rows, error)
- func (t *ArrowTableChunked) SetGeometryInfo(info map[string]GeometryInfo)
- func (t *ArrowTableChunked) SetInfo(info string)
- type ArrowTableStream
- func (t *ArrowTableStream) DecodeMsgpack(dec *msgpack.Decoder) error
- func (t *ArrowTableStream) EncodeMsgpack(enc *msgpack.Encoder) error
- func (t *ArrowTableStream) GeometryInfo() map[string]GeometryInfo
- func (t *ArrowTableStream) Info() string
- func (t *ArrowTableStream) MarshalJSON() ([]byte, error)
- func (t *ArrowTableStream) Reader(retain bool) (array.RecordReader, error)
- func (t *ArrowTableStream) Records() ([]arrow.RecordBatch, error)
- func (t *ArrowTableStream) Release()
- func (t *ArrowTableStream) Retain()
- func (t *ArrowTableStream) Rows() (Rows, error)
- func (t *ArrowTableStream) SetGeometryInfo(info map[string]GeometryInfo)
- func (t *ArrowTableStream) SetInfo(info string)
- type CatalogSource
- type CatalogSourceType
- type DataSource
- type DataSourceType
- type DateTime
- type EmbeddingResult
- type EmbeddingsResult
- type GeometryDecoder
- type GeometryInfo
- type JQRequest
- type JsonValue
- type LLMMessage
- type LLMOptions
- type LLMResult
- type LLMStreamEvent
- type LLMTool
- type LLMToolCall
- type ModelInfo
- type OperationResult
- type Querier
- type Request
- type Response
- func (r *Response) Close()
- func (r *Response) DataPart(path string) any
- func (r *Response) Err() error
- func (r *Response) Objects() []string
- func (r *Response) ScanData(path string, dest any) error
- func (r *Response) ScanDataJSON(path string, dest any) error
- func (r *Response) ScanObject(path string, dest any) error
- func (r *Response) ScanTable(path string, dest any) error
- func (r *Response) Table(path string) (ArrowTable, error)
- func (r *Response) Tables() []string
- type Rows
- type Subscription
- type SubscriptionEvent
- type UnloadOpt
- type UnloadOpts
- type UserIdentity
- type Vector
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoData = errors.New("no data") ErrWrongDataPath = errors.New("wrong data path") ErrGeometryDecode = errors.New("geometry decode") )
var ( // ErrScanBeforeNext is returned when Scan is called before the first Next. ErrScanBeforeNext = errors.New("types: Scan called before Next") // ErrScanAfterEnd is returned when Scan is called after Next returned false. ErrScanAfterEnd = errors.New("types: Scan called after end of stream") // ErrScanClosed is returned when any operation is attempted on a closed Rows. ErrScanClosed = errors.New("types: Rows is closed") // ErrScanNilDest is returned when Scan is passed a nil destination. ErrScanNilDest = errors.New("types: Scan dest is nil") // ErrScanNotPointer is returned when Scan's dest is not a non-nil pointer. ErrScanNotPointer = errors.New("types: Scan dest must be a non-nil pointer") )
Scanner state errors. All are wrapped by Rows.Scan when the call site violates the cursor contract; use errors.Is to match.
Functions ¶
func AsUser ¶ added in v0.3.21
AsUser returns a context that causes Query/Subscribe to execute as the specified user. Requires admin (secret key) authentication.
func FlattenRecord ¶ added in v0.3.6
func FlattenRecord(rec arrow.RecordBatch, mem memory.Allocator) arrow.RecordBatch
FlattenRecord transforms a record batch by recursively flattening Struct fields and converting List/Map/Union fields to JSON strings. If the record has no complex types, it is returned as-is (with Retain). The caller must Release the returned record.
func FlattenSchema ¶ added in v0.3.6
FlattenSchema returns the flattened schema without processing data.
func IsValidateOnlyContext ¶
func NeedsFlatten ¶ added in v0.3.6
NeedsFlatten returns true if the schema contains any complex types (Struct, List, Map, Union) that need transformation.
func ParseJsonValue ¶
func RecordToJSON ¶
func RecordToJSON(rec arrow.RecordBatch, asArray bool, w io.Writer, geomInfo map[string]GeometryInfo) error
RecordToJSON writes each row of rec as a JSON value into w. When asArray is true, rows are emitted as arrays of per-column values (single-column rows flatten to the column value directly, matching the today's "asArray" table shape for scalar-list query results). Otherwise rows are JSON objects keyed by schema field name.
geomInfo is the per-field geometry metadata attached to the containing ArrowTable (see ArrowTable.GeometryInfo()). Pass nil if you don't have one — the emitter then falls back to default rendering for every cell.
Timestamp / Date / Time / Interval / Decimal values use dedicated formatters (RFC3339Nano for timestamps; see record_json.go for the full matrix). Geometry extension columns (geoarrow.*, hugr.geojson) and GeoJSONString-annotated utf8 columns are emitted as GeoJSON objects. Rows are comma-separated but not wrapped in a `[...]` — the caller (MarshalJSON) owns the surrounding brackets.
func RecordsColNums ¶
func RecordsColNums(rr []arrow.RecordBatch) int64
func RecordsRowNums ¶
func RecordsRowNums(rr []arrow.RecordBatch) int64
func RegisterGeometryDecoder ¶ added in v0.3.31
func RegisterGeometryDecoder(name string, fn GeometryDecoder)
RegisterGeometryDecoder binds an Arrow extension name to a decoder. If the name is already registered, the new decoder replaces the old one. Passing a nil fn deletes the entry. Safe to call from init or at runtime; thread-safe via an internal RWMutex.
Example — register a decoder for a custom WKT+EWKT encoding:
func init() {
types.RegisterGeometryDecoder("myorg.geo.ewkt", func(
arr arrow.Array, row int, meta arrow.Metadata,
) (orb.Geometry, error) {
s := arr.(*array.String).Value(row)
return myparser.ParseEWKT(s)
})
}
func ReleaseRecords ¶
func ReleaseRecords(rr []arrow.RecordBatch)
func RetainRecords ¶
func RetainRecords(rr []arrow.RecordBatch)
func Scan ¶ added in v0.3.32
Scan is a generic dispatcher picking ScanTable vs ScanObject based on T's kind: slice → ScanTable, everything else → ScanObject. The same Go struct with orb.Geometry / orb.Point / time.Time fields works on both paths — the underlying scanners share geometry / time handling semantics.
Returns the zero value of T plus the underlying error on failure. resp == nil returns ErrNoData.
Originally contributed as PR #102 (Dmitriy Titov / DmitriyVTitov). Polished here to survive interface-valued T and to use the ErrNoData sentinel for consistency with the other scanner entry points.
func WarpGraphQLError ¶
Types ¶
type ArrowTable ¶
type ArrowTable interface {
SetInfo(info string)
Info() string
// SetGeometryInfo attaches per-field geometry metadata to this table.
// Populated by the query planner (engine side) or the IPC client reader
// (client side). Idempotent — last call wins. Not safe for concurrent
// set + read; the contract is "populate once before handing to consumers".
SetGeometryInfo(info map[string]GeometryInfo)
// GeometryInfo returns the attached per-field geometry metadata, or an
// empty non-nil map if none was set. Consumers use it to decide how to
// render / decode nested utf8 geometry columns on the JSON path, and
// (optionally) to dispatch the scanner without a byte-peek heuristic.
GeometryInfo() map[string]GeometryInfo
Retain()
Release()
MarshalJSON() ([]byte, error)
DecodeMsgpack(dec *msgpack.Decoder) error
EncodeMsgpack(enc *msgpack.Encoder) error
Records() ([]arrow.RecordBatch, error)
Reader(retain bool) (array.RecordReader, error)
// Rows returns a cursor over this table. The cursor retains the underlying
// Arrow resources; callers MUST call Close on the returned Rows.
Rows() (Rows, error)
}
type ArrowTableChunked ¶
type ArrowTableChunked struct {
// contains filtered or unexported fields
}
func NewArrowTable ¶
func NewArrowTable() *ArrowTableChunked
func NewArrowTableFromReader ¶
func NewArrowTableFromReader(reader array.RecordReader) (*ArrowTableChunked, error)
func (*ArrowTableChunked) Append ¶
func (t *ArrowTableChunked) Append(rec arrow.RecordBatch)
func (*ArrowTableChunked) Chunk ¶
func (t *ArrowTableChunked) Chunk(i int) arrow.RecordBatch
func (*ArrowTableChunked) DecodeMsgpack ¶
func (t *ArrowTableChunked) DecodeMsgpack(dec *msgpack.Decoder) error
func (*ArrowTableChunked) EncodeMsgpack ¶
func (t *ArrowTableChunked) EncodeMsgpack(enc *msgpack.Encoder) error
func (*ArrowTableChunked) GeometryInfo ¶ added in v0.3.32
func (t *ArrowTableChunked) GeometryInfo() map[string]GeometryInfo
func (*ArrowTableChunked) Info ¶
func (t *ArrowTableChunked) Info() string
func (*ArrowTableChunked) MarshalJSON ¶
func (t *ArrowTableChunked) MarshalJSON() ([]byte, error)
func (*ArrowTableChunked) NumChunks ¶
func (t *ArrowTableChunked) NumChunks() int
func (*ArrowTableChunked) NumCols ¶
func (t *ArrowTableChunked) NumCols() int
func (*ArrowTableChunked) NumRows ¶
func (t *ArrowTableChunked) NumRows() int
func (*ArrowTableChunked) Reader ¶
func (t *ArrowTableChunked) Reader(retain bool) (array.RecordReader, error)
func (*ArrowTableChunked) Records ¶
func (t *ArrowTableChunked) Records() ([]arrow.RecordBatch, error)
func (*ArrowTableChunked) Release ¶
func (t *ArrowTableChunked) Release()
func (*ArrowTableChunked) Retain ¶
func (t *ArrowTableChunked) Retain()
func (*ArrowTableChunked) RowData ¶
func (t *ArrowTableChunked) RowData(i int) (map[string]any, bool)
func (*ArrowTableChunked) Rows ¶ added in v0.3.31
func (t *ArrowTableChunked) Rows() (Rows, error)
Rows returns a cursor-style scanner over this table. The cursor takes a retained reference to the underlying record reader; callers MUST call Close on the returned Rows (or let it reach end-of-stream).
func (*ArrowTableChunked) SetGeometryInfo ¶ added in v0.3.32
func (t *ArrowTableChunked) SetGeometryInfo(info map[string]GeometryInfo)
func (*ArrowTableChunked) SetInfo ¶
func (t *ArrowTableChunked) SetInfo(info string)
type ArrowTableStream ¶
type ArrowTableStream struct {
// contains filtered or unexported fields
}
func NewArrowTableStream ¶
func NewArrowTableStream(reader array.RecordReader) *ArrowTableStream
func (*ArrowTableStream) DecodeMsgpack ¶
func (t *ArrowTableStream) DecodeMsgpack(dec *msgpack.Decoder) error
func (*ArrowTableStream) EncodeMsgpack ¶
func (t *ArrowTableStream) EncodeMsgpack(enc *msgpack.Encoder) error
func (*ArrowTableStream) GeometryInfo ¶ added in v0.3.32
func (t *ArrowTableStream) GeometryInfo() map[string]GeometryInfo
func (*ArrowTableStream) Info ¶
func (t *ArrowTableStream) Info() string
func (*ArrowTableStream) MarshalJSON ¶
func (t *ArrowTableStream) MarshalJSON() ([]byte, error)
func (*ArrowTableStream) Reader ¶
func (t *ArrowTableStream) Reader(retain bool) (array.RecordReader, error)
func (*ArrowTableStream) Records ¶
func (t *ArrowTableStream) Records() ([]arrow.RecordBatch, error)
func (*ArrowTableStream) Release ¶
func (t *ArrowTableStream) Release()
func (*ArrowTableStream) Retain ¶
func (t *ArrowTableStream) Retain()
func (*ArrowTableStream) Rows ¶ added in v0.3.31
func (t *ArrowTableStream) Rows() (Rows, error)
Rows returns a cursor-style scanner over this streaming table. The cursor consumes the underlying reader; callers MUST call Close on the returned Rows (or let it reach end-of-stream).
func (*ArrowTableStream) SetGeometryInfo ¶ added in v0.3.32
func (t *ArrowTableStream) SetGeometryInfo(info map[string]GeometryInfo)
func (*ArrowTableStream) SetInfo ¶
func (t *ArrowTableStream) SetInfo(info string)
type CatalogSource ¶
type CatalogSource struct {
Name string `json:"name"`
Type CatalogSourceType `json:"type"`
Path string `json:"path"`
Description string `json:"description"`
}
type CatalogSourceType ¶
type CatalogSourceType string
type DataSource ¶
type DataSource struct {
Name string `json:"name"`
Description string `json:"description"`
Type DataSourceType `json:"type"`
Prefix string `json:"prefix"`
Path string `json:"path"`
AsModule bool `json:"as_module"`
SelfDefined bool `json:"self_defined"`
ReadOnly bool `json:"read_only"`
Disabled bool `json:"disabled"`
Sources []CatalogSource `json:"catalogs"`
}
type DataSourceType ¶
type DataSourceType string
type DateTime ¶ added in v0.3.11
DateTime represents a naive date-time value WITHOUT timezone. Used by the DateTime scalar to distinguish from Timestamp (which uses time.Time directly). Engine SQLValue dispatches on this type to cast as TIMESTAMP instead of TIMESTAMPTZ.
type EmbeddingResult ¶ added in v0.3.16
type EmbeddingResult struct {
Vector Vector `json:"vector"`
PromptTokens int `json:"prompt_tokens"`
TokenCount int `json:"token_count"`
}
EmbeddingResult is an enriched embedding response with token count.
type EmbeddingsResult ¶ added in v0.3.16
type EmbeddingsResult struct {
Vectors []Vector `json:"vectors"`
TokenCount int `json:"token_count"`
PromptTokens int `json:"prompt_tokens"`
}
EmbeddingsResult is a batch embedding response with total token count.
type GeometryDecoder ¶ added in v0.3.31
GeometryDecoder converts an Arrow cell into an orb.Geometry. It is registered against an Arrow extension name via RegisterGeometryDecoder. The scanner invokes a decoder when the destination Go type is orb.Geometry (or a concrete subtype) and the column carries that extension name — either via an ExtensionArray's ExtensionType().ExtensionName() or via an ARROW:extension:name entry in the column's field metadata.
Built-in decoders are registered for: geoarrow.wkb, geoarrow.wkt, geoarrow.point, geoarrow.linestring, geoarrow.polygon, geoarrow.multipoint, geoarrow.multilinestring, geoarrow.multipolygon, hugr.geojson. The native union forms geoarrow.geometry and geoarrow.geometrycollection are registered as stub decoders that error clearly — override them if your data actually carries those encodings.
Return (nil, nil) for a cell that is logically null; the scanner zeroes the destination in that case.
type GeometryInfo ¶ added in v0.3.32
type GeometryInfo struct {
SRID string `json:"srid" msgpack:"srid"`
Format string `json:"format" msgpack:"format"`
}
GeometryInfo describes the wire format of a single geometry field inside an Arrow table or response. Same vocabulary as the IPC X-Hugr-Geometry-Fields header: Format is one of "WKB", "GeoJSON", or "GeoJSONString".
Keys in map[string]GeometryInfo are dotted field paths resolvable against the Arrow schema; empty string means the whole row / value.
type LLMMessage ¶ added in v0.3.16
type LLMMessage struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []LLMToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ThoughtSignature string `json:"thought_signature,omitempty"` // Gemini 2.5+ / Anthropic: encrypted signature for multi-turn continuity
Thinking string `json:"thinking,omitempty"` // Anthropic thinking text / OpenAI reasoning summary
}
LLMMessage is a single message in a chat conversation.
type LLMOptions ¶ added in v0.3.16
type LLMOptions struct {
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
Stop []string `json:"stop,omitempty"`
Tools []LLMTool `json:"tools,omitempty"`
ToolChoice string `json:"tool_choice,omitempty"`
ThinkingBudget int `json:"thinking_budget,omitempty"` // Token budget for reasoning/thinking (Anthropic, Gemini)
}
LLMOptions configures an LLM request.
type LLMResult ¶ added in v0.3.16
type LLMResult struct {
Content string `json:"content"`
Model string `json:"model"`
FinishReason string `json:"finish_reason"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
Provider string `json:"provider"`
LatencyMs int `json:"latency_ms"`
ToolCalls []LLMToolCall `json:"tool_calls"`
ThoughtSignature string `json:"thought_signature,omitempty"` // Gemini 2.5+ / Anthropic: encrypted signature
Thinking string `json:"thinking,omitempty"` // Anthropic thinking text / OpenAI reasoning summary
}
LLMResult is the normalized response from any LLM provider.
type LLMStreamEvent ¶ added in v0.3.20
type LLMStreamEvent struct {
Type string `json:"type"` // content_delta, reasoning, tool_use, finish, error
Content string `json:"content"` // Token content (content_delta, reasoning)
Model string `json:"model"` // Model identifier
FinishReason string `json:"finish_reason"` // stop, length, tool_use (finish only)
ToolCalls string `json:"tool_calls"` // JSON-encoded tool calls (tool_use only)
PromptTokens int `json:"prompt_tokens"` // Input token count (finish only)
CompletionTokens int `json:"completion_tokens"` // Output token count (finish only)
ThoughtSignature string `json:"thought_signature"` // Gemini 2.5+ / Anthropic: encrypted signature (finish only)
Thinking string `json:"thinking"` // Anthropic thinking text / OpenAI reasoning summary (finish only)
}
LLMStreamEvent is a single event from a streaming LLM completion.
type LLMTool ¶ added in v0.3.16
type LLMTool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters any `json:"parameters"`
}
LLMTool is a tool definition provided to the model.
type LLMToolCall ¶ added in v0.3.16
type LLMToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments any `json:"arguments"`
}
LLMToolCall is a tool invocation from the model.
type ModelInfo ¶ added in v0.3.16
type ModelInfo struct {
Name string `json:"name"`
Type string `json:"type"` // "llm" or "embedding"
Provider string `json:"provider"` // "openai", "anthropic", "gemini"
Model string `json:"model"`
}
ModelInfo describes a registered AI model data source.
type OperationResult ¶
type OperationResult struct {
Succeed bool `json:"success"`
Msg string `json:"message"`
Rows int `json:"affected_rows"`
LastId int `json:"last_id"`
}
func ErrResult ¶
func ErrResult(err error) *OperationResult
func Result ¶
func Result(msg string, rows, lastId int) *OperationResult
func SQLError ¶
func SQLError(msg string, err error) *OperationResult
func (*OperationResult) CollectSQL ¶
func (r *OperationResult) CollectSQL(res sql.Result)
func (*OperationResult) ToDuckdb ¶
func (r *OperationResult) ToDuckdb() map[string]any
type Querier ¶
type Querier interface {
Query(ctx context.Context, query string, vars map[string]any) (*Response, error)
Subscribe(ctx context.Context, query string, vars map[string]any) (*Subscription, error)
RegisterDataSource(ctx context.Context, ds DataSource) error
LoadDataSource(ctx context.Context, name string) error
UnloadDataSource(ctx context.Context, name string, opts ...UnloadOpt) error
DataSourceStatus(ctx context.Context, name string) (string, error)
DescribeDataSource(ctx context.Context, name string, self bool) (string, error)
}
type Response ¶
type Response struct {
Data map[string]any `json:"data,omitempty"`
Extensions map[string]any `json:"extensions,omitempty"`
Errors gqlerror.List `json:"errors,omitempty"`
}
func ErrResponse ¶
func (*Response) Objects ¶ added in v0.3.31
Objects returns every dotted path in Response.Data that points to a leaf value that is NOT an ArrowTable — most commonly a *types.JsonValue emitted for object-shaped GraphQL selections (by_pk results, function calls, etc.), but also raw scalars or slices. map[string]any values are treated as namespaces and descended into. Together with Tables this covers every meaningful leaf in the response tree.
func (*Response) ScanData ¶
ScanData navigates Response.Data down a dotted path and deserialises the leaf into dest. It is the generic scan API sitting above the typed Scan[T] / ScanObject / ScanTable helpers.
Leaf dispatch:
- Table leaves (types.ArrowTable) go through the native Arrow row scanner (same path as ScanTable) — no JSON round-trip. dest must be a pointer to a slice; geometry / time / decimal are decoded column-wise via the reflect-plan-backed row scanner.
- Object leaves (*types.JsonValue) pass their raw JSON bytes to the geometry-aware scanObject decoder.
- Scalar / map / slice leaves marshal via stdlib json and go through the same scanObject decoder.
Callers that need stdlib-json behaviour on table leaves (no-tag field matching by Go name, json.RawMessage, custom UnmarshalJSON, encoding.TextUnmarshaler) should use ScanDataJSON, which forces the JSON path on every leaf type.
Error semantics: missing path segment → ErrWrongDataPath, present-but-nil leaf → ErrNoData.
func (*Response) ScanDataJSON ¶ added in v0.3.33
ScanDataJSON is ScanData's sibling that forces the stdlib-JSON path even for ArrowTable leaves. Use when the destination type depends on encoding/json behaviour the native row scanner does not cover:
- fields without a json tag matched by Go field name,
- json.RawMessage fields,
- types with custom UnmarshalJSON / TextUnmarshaler / BinaryUnmarshaler.
Tables are rendered via ArrowTable.MarshalJSON (extension-aware RecordToJSON — geometry as GeoJSON, timestamps as RFC3339Nano) and then unmarshalled through the geometry-aware scanObject decoder, so orb.Geometry / time.Time still work. *JsonValue leaves bypass the remarshal exactly as in ScanData.
Prefer ScanData for the fast path. ScanDataJSON is the escape hatch.
func (*Response) ScanObject ¶ added in v0.3.31
ScanObject decodes a non-table leaf at `path` into `dest`. Returns ErrWrongDataPath if the path refers to an ArrowTable.
Destinations containing orb.Geometry / orb.Point / … fields are decoded via the reflect-plan-backed geometry-aware decoder (see scanner_object.go). Destinations without such fields fall through to stdlib json.Unmarshal as before — no performance change for plain structs.
func (*Response) ScanTable ¶ added in v0.3.31
ScanTable reads every row of the ArrowTable at path into dest. dest MUST be a non-nil pointer to a slice (struct elements or map[string]any elements). On mid-stream error the slice is left truncated to the prefix of successfully-scanned rows and the error is returned.
type Rows ¶ added in v0.3.31
type Rows interface {
// Next advances the cursor to the next row. Returns false at end-of-stream
// or on error; inspect Err() to distinguish. Calling Next after it returned
// false is safe and returns false.
Next() bool
// Scan copies the current row into dest. dest MUST be a non-nil pointer to
// a struct, a map[string]any, a slice []any, or interface{}.
// Struct fields are resolved by `json` tag (matching Response.ScanData).
Scan(dest any) error
// Err returns the first error encountered during iteration, if any.
Err() error
// Close releases any Arrow resources held by the cursor. Idempotent.
// Reaching end-of-stream via Next auto-releases the last retained batch;
// explicit Close is required only for early exit from the iteration.
Close() error
// Columns returns the Arrow schema column names in positional order
// (matches the []any Scan destination order).
Columns() []string
}
Rows is a cursor over the rows of an ArrowTable. The shape follows database/sql.Rows. A Rows is NOT safe for concurrent use across goroutines.
Typical use:
tbl, _ := resp.Table("core.users")
rows, _ := tbl.Rows()
defer rows.Close()
for rows.Next() {
var u User
if err := rows.Scan(&u); err != nil { return err }
// ...
}
if err := rows.Err(); err != nil { return err }
type Subscription ¶ added in v0.3.20
type Subscription struct {
Events <-chan SubscriptionEvent
Cancel func()
// contains filtered or unexported fields
}
Subscription is the result of Querier.Subscribe. Events channel produces SubscriptionEvents until closed. Errors are reported via Reader.Err() after Reader.Next() returns false, or via Err() after Events is closed (for subscription-level errors).
func (*Subscription) Err ¶ added in v0.3.25
func (s *Subscription) Err() error
Err returns the subscription-level error (e.g. from subscription_error frame). Call after Events channel is closed.
func (*Subscription) SetErr ¶ added in v0.3.25
func (s *Subscription) SetErr(err error)
SetErr sets the subscription-level error. Called by the transport layer.
type SubscriptionEvent ¶ added in v0.3.20
type SubscriptionEvent struct {
Path string // Data object path (e.g. "core.data_sources"). Empty for native subscriptions.
Reader array.RecordReader // Data reader. Transport decides how to consume: graphql-ws reads all → JSON next; IPC streams batches.
}
SubscriptionEvent is a data event in the subscription stream. One event per data path (query) or per native source event batch. Metadata (geometry, table info) is in Reader's Arrow schema metadata.
type UnloadOpt ¶ added in v0.3.18
type UnloadOpt func(*UnloadOpts)
func WithHardUnload ¶ added in v0.3.18
func WithHardUnload() UnloadOpt
type UnloadOpts ¶ added in v0.3.18
type UnloadOpts struct {
Hard bool
}
type UserIdentity ¶ added in v0.3.21
UserIdentity represents an impersonated user identity. When set in context via AsUser, queries and subscriptions execute as this user with this role's permissions.
func AsUserFromContext ¶ added in v0.3.21
func AsUserFromContext(ctx context.Context) *UserIdentity
AsUserFromContext extracts impersonation identity from context.
type Vector ¶ added in v0.3.16
type Vector []float64