Documentation
¶
Index ¶
- Constants
- func FlightHeadersInterceptor(headers map[string]string) grpc.UnaryClientInterceptor
- func GetOSRelease() string
- func GetOrCreateTracer(traceName string) trace.Tracer
- func GetSpiceUserAgent() string
- func RemoveNonPrintableASCII(str string) string
- type ADBCClient
- type ClientConfig
- type DatasetRefreshRequest
- type Param
- func BinaryParam(value []byte) Param
- func BoolParam(value bool) Param
- func Date32Param(value arrow.Date32) Param
- func Date64Param(value arrow.Date64) Param
- func DayTimeIntervalParam(value arrow.DayTimeInterval) Param
- func Decimal128Param(value [16]byte, precision, scale int32) Param
- func Decimal256Param(value [32]byte, precision, scale int32) Param
- func DurationParam(value arrow.Duration, unit arrow.TimeUnit) Param
- func FixedSizeBinaryParam(value []byte, byteWidth int) Param
- func Float16Param(value uint16) Param
- func Float32Param(value float32) Param
- func Float64Param(value float64) Param
- func Int8Param(value int8) Param
- func Int16Param(value int16) Param
- func Int32Param(value int32) Param
- func Int64Param(value int64) Param
- func LargeBinaryParam(value []byte) Param
- func LargeStringParam(value string) Param
- func MonthDayNanoIntervalParam(value arrow.MonthDayNanoInterval) Param
- func MonthIntervalParam(value arrow.MonthInterval) Param
- func NewParam(value any) Param
- func NewTypedParam(value any, dataType arrow.DataType) Param
- func NullParam() Param
- func StringParam(value string) Param
- func Time32Param(value arrow.Time32, unit arrow.TimeUnit) Param
- func Time64Param(value arrow.Time64, unit arrow.TimeUnit) Param
- func TimestampParam(value arrow.Timestamp, unit arrow.TimeUnit, timezone string) Param
- func Uint8Param(value uint8) Param
- func Uint16Param(value uint16) Param
- func Uint32Param(value uint32) Param
- func Uint64Param(value uint64) Param
- type RefreshMode
- type SpiceClient
- func (c *SpiceClient) Close() error
- func (c *SpiceClient) Init(opts ...SpiceClientModifier) error
- func (c *SpiceClient) IsSpiceHealthy(ctx context.Context) bool
- func (c *SpiceClient) IsSpiceReady(ctx context.Context) bool
- func (c *SpiceClient) Query(ctx context.Context, sql string) (array.RecordReader, error)
- func (c *SpiceClient) QueryWithParams(ctx context.Context, sql string, params ...any) (array.RecordReader, error)
- func (c *SpiceClient) RefreshDataset(ctx context.Context, dataset string, opts *DatasetRefreshRequest) error
- func (c *SpiceClient) SetMaxRetries(maxRetries uint)
- func (c *SpiceClient) Sql(ctx context.Context, sql string) (array.RecordReader, error)
- func (c *SpiceClient) SqlWithParams(ctx context.Context, sql string, params ...any) (array.RecordReader, error)
- type SpiceClientModifier
Constants ¶
const GO_SPICE_VERSION = "8.0.0"
const (
MAX_MESSAGE_SIZE_BYTES = 100 * 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
func FlightHeadersInterceptor ¶
func FlightHeadersInterceptor(headers map[string]string) grpc.UnaryClientInterceptor
func GetOSRelease ¶
func GetOSRelease() string
func GetOrCreateTracer ¶
GetOrCreateTracer adds a new tracer to the global tracer provider if one doesn't already exist
func GetSpiceUserAgent ¶
func GetSpiceUserAgent() string
func RemoveNonPrintableASCII ¶
Types ¶
type ADBCClient ¶
type ADBCClient struct {
// contains filtered or unexported fields
}
ADBCClient wraps ADBC database and connection for Spice.ai
type ClientConfig ¶
type ClientConfig struct {
HttpUrl string `json:"http_url,omitempty"`
FlightUrl string `json:"flight_url,omitempty"`
}
func LoadConfig ¶
func LoadConfig() ClientConfig
func LoadLocalConfig ¶
func LoadLocalConfig() ClientConfig
type DatasetRefreshRequest ¶
type DatasetRefreshRequest struct {
RefreshSQL *string `json:"refresh_sql,omitempty"`
Mode *RefreshMode `json:"refresh_mode,omitempty"`
MaxJitter *string `json:"refresh_jitter_max,omitempty"`
}
type Param ¶
Param represents a query parameter with an optional explicit Arrow type. If Type is nil, the type will be inferred from the Value.
func Date32Param ¶
Date32Param creates a Date32 parameter
func Date64Param ¶
Date64Param creates a Date64 parameter
func DayTimeIntervalParam ¶
func DayTimeIntervalParam(value arrow.DayTimeInterval) Param
DayTimeIntervalParam creates a DayTimeInterval parameter
func Decimal128Param ¶
Decimal128Param creates a Decimal128 parameter with specified precision and scale
func Decimal256Param ¶
Decimal256Param creates a Decimal256 parameter with specified precision and scale
func DurationParam ¶
DurationParam creates a Duration parameter with specified unit
func FixedSizeBinaryParam ¶
FixedSizeBinaryParam creates a FixedSizeBinary parameter with specified byte width
func LargeBinaryParam ¶
LargeBinaryParam creates a large binary parameter
func LargeStringParam ¶
LargeStringParam creates a large string parameter
func MonthDayNanoIntervalParam ¶
func MonthDayNanoIntervalParam(value arrow.MonthDayNanoInterval) Param
MonthDayNanoIntervalParam creates a MonthDayNanoInterval parameter
func MonthIntervalParam ¶
func MonthIntervalParam(value arrow.MonthInterval) Param
MonthIntervalParam creates a MonthInterval parameter
func NewTypedParam ¶
NewTypedParam creates a new parameter with explicit type
func Time32Param ¶
Time32Param creates a Time32 parameter with specified unit
func Time64Param ¶
Time64Param creates a Time64 parameter with specified unit
func TimestampParam ¶
TimestampParam creates a Timestamp parameter with specified unit and timezone
type RefreshMode ¶
type RefreshMode string
const ( RefreshModeFull RefreshMode = "full" RefreshModeAppend RefreshMode = "append" )
type SpiceClient ¶
type SpiceClient struct {
// contains filtered or unexported fields
}
SpiceClient is a client for Spice.ai OSS, a unified SQL query interface and portable runtime to locally materialize, accelerate, and query datasets across databases, data warehouses, and data lakes.
https://spiceai.org For documentation visit https://docs.spiceai.org/sdks/golang
func NewSpiceClientWithAddress ¶
func NewSpiceClientWithAddress(flightAddress string) *SpiceClient
func (*SpiceClient) Close ¶
func (c *SpiceClient) Close() error
Close closes the SpiceClient and cleans up resources
func (*SpiceClient) Init ¶
func (c *SpiceClient) Init(opts ...SpiceClientModifier) error
Init initializes the SpiceClient
func (*SpiceClient) IsSpiceHealthy ¶
func (c *SpiceClient) IsSpiceHealthy(ctx context.Context) bool
IsSpiceHealthy checks if the Spice instance is healthy by calling the /health endpoint. This is an unauthenticated endpoint that returns 200 OK with "ok" in the body if the instance is healthy. Returns true if healthy, false otherwise.
func (*SpiceClient) IsSpiceReady ¶
func (c *SpiceClient) IsSpiceReady(ctx context.Context) bool
IsSpiceReady checks if the Spice instance is ready to accept queries by calling the /v1/ready endpoint. For Spice Cloud, this endpoint requires authentication via API key. For local Spice instances, no API key is required. Returns "ready" in the body when ready. Returns true if ready, false otherwise.
func (*SpiceClient) Query ¶
func (c *SpiceClient) Query(ctx context.Context, sql string) (array.RecordReader, error)
Query is deprecated. Use Sql instead. Kept for backward compatibility with v7.
func (*SpiceClient) QueryWithParams ¶
func (c *SpiceClient) QueryWithParams(ctx context.Context, sql string, params ...any) (array.RecordReader, error)
QueryWithParams is deprecated. Use SqlWithParams instead. Kept for backward compatibility with v7.
func (*SpiceClient) RefreshDataset ¶
func (c *SpiceClient) RefreshDataset(ctx context.Context, dataset string, opts *DatasetRefreshRequest) error
func (*SpiceClient) SetMaxRetries ¶
func (c *SpiceClient) SetMaxRetries(maxRetries uint)
Sets the maximum number of times to retry Query and FireQuery calls. The default is 3. Setting to 0 will disable retries.
func (*SpiceClient) Sql ¶
func (c *SpiceClient) Sql(ctx context.Context, sql string) (array.RecordReader, error)
Sql executes a SQL query against Spice.ai and returns an Apache Arrow RecordReader For more information on Apache Arrow RecordReader visit https://godoc.org/github.com/apache/arrow/go/arrow/array#RecordReader
func (*SpiceClient) SqlWithParams ¶
func (c *SpiceClient) SqlWithParams(ctx context.Context, sql string, params ...any) (array.RecordReader, error)
SqlWithParams executes a parameterized SQL query against Spice.ai and returns an Apache Arrow RecordReader This is the recommended method for querying with parameters to prevent SQL injection Parameters should use positional placeholders (e.g., $1, $2) in the SQL query
Parameters can be: - Simple Go values (int, string, bool, etc.) - type will be inferred - Param structs with explicit type annotation using NewTypedParam() or helper functions - Arrow types (arrow.Date32, arrow.Timestamp, etc.)
Example:
reader, err := client.SqlWithParams(ctx, "SELECT * FROM table WHERE id = $1 AND name = $2", 123, "test") reader, err := client.SqlWithParams(ctx, "SELECT * FROM table WHERE ts = $1", TimestampParam(ts, arrow.Microsecond, "UTC"))
type SpiceClientModifier ¶
type SpiceClientModifier func(c *SpiceClient) error
func WithApiKey ¶
func WithApiKey(apiKey string) SpiceClientModifier
func WithFlightAddress ¶
func WithFlightAddress(address string) SpiceClientModifier
func WithHttpAddress ¶
func WithHttpAddress(address string) SpiceClientModifier
func WithSpiceCloudAddress ¶
func WithSpiceCloudAddress() SpiceClientModifier
func WithUserAgent ¶
func WithUserAgent(userAgent string) SpiceClientModifier