exporttable

package
v1.134.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package exporttable is the register= argument of a managed script's platform.export (#1820): what it may ask for, which outputs it applies to, the manage_table call it becomes, and what that call reports back.

It exists so one call can land rows in a file and make the file a table. Before it, the path from script rows to a queryable table was three calls a script had to get right in order -- export, find the reference, register -- and it was also the only path free text had into SQL, because trino_execute binds no parameters. The registration is not a second mechanism: it is the same manage_table register a script could call itself, issued over the run's own session, so it is authorized and audited the way that call is.

It knows nothing about Starlark or about the run. The host binding hands it plain Go values and the tool's structured result.

Index

Constants

View Source
const (
	Tool   = "manage_table"
	Action = "register"
)

Tool and Action are the call a registration becomes.

Variables

This section is empty.

Functions

func Reference

func Reference(resourceRef, assetID string) string

Reference names the stored file an export wrote, the way manage_table takes it: the managed resource's reference for a library output, and the asset's for a portal one.

Types

type Spec

type Spec struct {
	// Connection is the Trino connection whose scratch schema the table goes
	// in. Required.
	Connection string
	// TableName is the table's name before the persona prefix. Empty takes a
	// slug of the file's name, as manage_table does.
	TableName string
	// Follow moves the table onto each later version of the file. It defaults
	// to true, as manage_table's does: a script that exports to one key every
	// run wants the table to read the latest run.
	Follow bool
}

Spec is what a register= argument asks for.

func Parse

func Parse(v any) (*Spec, error)

Parse reads a register= value, already converted from Starlark to plain Go. nil means the argument was not passed, and yields a nil Spec.

func (*Spec) Args

func (s *Spec) Args(reference string) map[string]any

Args renders the manage_table call that registers the file a reference names.

func (*Spec) Check

func (*Spec) Check(format string, stored bool) error

Check refuses a registration the output cannot carry, before the output is written: an export whose format no reader registers, and one delivered out of the platform, which leaves no stored file for a table to point at.

func (*Spec) Preview

func (s *Spec) Preview() *Table

Preview is the Table a draft reports for a registration it did not make.

type Table

type Table struct {
	Connection     string   `json:"connection"`
	QueryTable     string   `json:"query_table,omitempty"`
	RegistrationID string   `json:"registration_id,omitempty"`
	Columns        []string `json:"columns,omitempty"`
	Format         string   `json:"format,omitempty"`
	Follow         bool     `json:"follow"`
	// Preview marks a registration a draft reports rather than makes: the
	// output was not written, so there was no file to register.
	Preview bool `json:"preview,omitempty"`
}

Table is the registration an export made, or would have made.

func FromResult

func FromResult(out map[string]any) *Table

FromResult reads the registration out of manage_table's structured result.

func (*Table) Map

func (t *Table) Map() map[string]any

Map renders a Table as the plain value a script receives.

Jump to

Keyboard shortcuts

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