Documentation
¶
Index ¶
- func Compile(filter string, mode InputMode) (*gojq.Code, error)
- func DefaultFilter(InputMode) string
- func Execute(code *gojq.Code, mode InputMode, rowIter *spanner.RowIterator, ...) (gojq.Iter, func(), error)
- func MetadataMapFromMetadata(metadata *sppb.ResultSetMetadata) (map[string]any, error)
- func NormalizeForEncode(v any) (any, error)
- func Print(enc Encoder, iter gojq.Iter) error
- func ProtoToMap(m proto.Message) (map[string]any, error)
- func ResultSetMap(rs *sppb.ResultSet) (map[string]any, error)
- func ResultSetMapFromRowIterator(rowIter *spanner.RowIterator, redact bool, opts ...spaniter.Option) (map[string]any, error)
- func RowToJSON(r *spanner.Row) (any, error)
- func StatsMapFromResult(result spaniter.RowIteratorResult) (map[string]any, error)
- type Encoder
- type InputMode
- type Lazy
- func (l *Lazy) JQValueEach() any
- func (l *Lazy) JQValueHas(key any) any
- func (l *Lazy) JQValueIndex(int) any
- func (l *Lazy) JQValueKey(name string) any
- func (l *Lazy) JQValueKeys() any
- func (l *Lazy) JQValueLength() any
- func (l *Lazy) JQValueSlice(int, int) any
- func (l *Lazy) JQValueSliceLen() any
- func (l *Lazy) JQValueToGoJQ() any
- func (l *Lazy) JQValueToNumber() any
- func (l *Lazy) JQValueToString() any
- func (l *Lazy) JQValueType() string
- func (l *Lazy) Stop()
- type RowIter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultFilter ¶
DefaultFilter returns the filter used when the user passes an empty --filter.
func Execute ¶
func Execute(code *gojq.Code, mode InputMode, rowIter *spanner.RowIterator, rs *sppb.ResultSet, redactRows bool) (gojq.Iter, func(), error)
Execute runs jq. For eager mode, rs must be set and rowIter is ignored. For lazy mode, rowIter must be unread; cleanup releases the iterator state. Lazy mode is intended for read-only queries; read-write callers should materialize first and use eager mode.
func MetadataMapFromMetadata ¶
func MetadataMapFromMetadata(metadata *sppb.ResultSetMetadata) (map[string]any, error)
MetadataMapFromMetadata returns the metadata object for jq input.
func NormalizeForEncode ¶
NormalizeForEncode walks v and expands gojq.Iter and gojq.JQValue so encoding/json or yaml can encode the result. jq-compatible containers ([]any, map[string]any) are recursed; other concrete values are left as leaves.
func Print ¶
Print writes all values from a jq iterator. Top-level gojq.Iter values are expanded to one Encode per element (JSONL-friendly). Other values are normalized (including nested Iter) then encoded once.
func ProtoToMap ¶
ProtoToMap marshals a protobuf message with protojson and decodes to map[string]any.
func ResultSetMap ¶
ResultSetMap materializes a full ResultSet as a jq input map (eager mode).
func ResultSetMapFromRowIterator ¶
func ResultSetMapFromRowIterator(rowIter *spanner.RowIterator, redact bool, opts ...spaniter.Option) (map[string]any, error)
ResultSetMapFromRowIterator materializes rowIter and returns the jq input map.
func RowToJSON ¶
RowToJSON encodes one row the same way as protojson on a single-row ResultSet (array-shaped row).
func StatsMapFromResult ¶
func StatsMapFromResult(result spaniter.RowIteratorResult) (map[string]any, error)
StatsMapFromResult returns the stats object for jq input from captured iterator state.
Types ¶
type InputMode ¶
type InputMode string
InputMode selects how Spanner query results are passed to gojq.
func ParseInputMode ¶
func (InputMode) ValidateFormat ¶
ValidateFormat returns an error when mode is incompatible with the output format.
type Lazy ¶
type Lazy struct {
// contains filtered or unexported fields
}
Lazy is a JQValue root for a Spanner query result. Accessing stats drains rows; rows streams via gojq.Iter.
func NewLazy ¶
func NewLazy(rowIter *spanner.RowIterator, redact bool) *Lazy
NewLazy builds a lazy jq input. rowIter must not have been read yet; Lazy takes ownership and Stop()s it.
func (*Lazy) JQValueEach ¶
func (*Lazy) JQValueHas ¶
func (*Lazy) JQValueIndex ¶
func (*Lazy) JQValueKey ¶
func (*Lazy) JQValueKeys ¶
func (*Lazy) JQValueLength ¶
func (*Lazy) JQValueSliceLen ¶
func (*Lazy) JQValueToGoJQ ¶
func (*Lazy) JQValueToNumber ¶
func (*Lazy) JQValueToString ¶
func (*Lazy) JQValueType ¶
type RowIter ¶
type RowIter struct {
// contains filtered or unexported fields
}
RowIter streams query rows as jq-compatible values ([]any per row, matching protojson ResultSet rows).
func NewRowIter ¶
func (*RowIter) Drain ¶
Drain exhausts the Spanner row iterator. When redact is false, drained rows are returned.
func (*RowIter) Prime ¶
Prime reads the first row (or iterator.Done) so metadata is populated. The first row is buffered for the next Next call when present.
func (*RowIter) Result ¶
func (r *RowIter) Result() spaniter.RowIteratorResult
Result returns lifecycle data captured by spaniter while rows are consumed.