Documentation
¶
Overview ¶
Adapted from cedricziel/datafusion-golang (Apache-2.0), commit 54272e7.
Index ¶
- Variables
- type And
- type Between
- type CatalogProvider
- type Column
- type Compare
- type CompareOp
- type Connection
- func (conn *Connection) Close()
- func (conn *Connection) DeregisterTable(name string) error
- func (conn *Connection) NewImport(name string) (*Import, error)
- func (conn *Connection) Prepare(query string) (*Statement, error)
- func (conn *Connection) RegisterArrowIPC(name string, data []byte) error
- func (conn *Connection) RegisterArrowReaderZeroCopy(name string, reader array.RecordReader) error
- func (conn *Connection) RegisterFFITableProvider(name string, provider unsafe.Pointer, providerDataFusionVersion string) error
- func (conn *Connection) RegisterGo(name string, object any, kind int) error
- type Database
- type DateParameter
- type DecimalParameter
- type DiscoverableCatalogProvider
- type DurationParameter
- type Error
- type Expr
- type Import
- type InList
- type InsertOp
- type IsNull
- type Literal
- type LiteralType
- type Not
- type NullParameter
- type Or
- type ParameterType
- type PushdownTableProvider
- type RecordReader
- type ScalarFunction
- type ScanOptions
- type Statement
- type TableProvider
- type TimeParameter
- type TimeUnit
- type TimestampParameter
- type UInt64Parameter
- type Volatility
- type WritableTableProvider
Constants ¶
This section is empty.
Variables ¶
var ( ErrCancelled = errors.New("datafusion native query canceled") ErrInvalidArgument = errors.New("datafusion native invalid argument") ErrFailure = errors.New("datafusion native failure") ErrPanic = errors.New("datafusion native panic") )
Shared sentinels let Arrow-native errors and the database/sql adapter expose the same classifications without an import cycle or matching error text.
Functions ¶
This section is empty.
Types ¶
type Between ¶ added in v0.550100.0
Between is a [NOT] BETWEEN test with literal bounds (both inclusive).
type CatalogProvider ¶ added in v0.550100.0
type CatalogProvider interface {
ResolveTable(ctx context.Context, schema, table string) (TableProvider, error)
}
CatalogProvider lazily resolves tables into a per-query snapshot. Return nil, nil for a missing table. Remote I/O must honor ctx. Repeated references share one resolved provider within a query; subsequent queries resolve afresh. Discovery/listing is deliberately separate from query-time resolution.
type Column ¶ added in v0.550100.0
Column identifies a column of the registered table schema, by name and by index into that schema. Both refer to the full registered schema, independent of the scan's projection.
type Compare ¶ added in v0.550100.0
Compare is a comparison between a column and a literal. The column is always on the left: the engine normalizes mirrored predicates (2 < id becomes id > 2) before pushing them down.
type CompareOp ¶ added in v0.550100.0
type CompareOp string
CompareOp is a comparison operator in a pushed-down predicate.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func (*Connection) Close ¶
func (conn *Connection) Close()
func (*Connection) DeregisterTable ¶ added in v0.530100.2
func (conn *Connection) DeregisterTable(name string) error
DeregisterTable removes a table previously registered on the connection's session. Removing a name that is not registered is not an error.
func (*Connection) NewImport ¶ added in v0.550100.0
func (conn *Connection) NewImport(name string) (*Import, error)
func (*Connection) RegisterArrowIPC ¶
func (conn *Connection) RegisterArrowIPC(name string, data []byte) error
func (*Connection) RegisterArrowReaderZeroCopy ¶
func (conn *Connection) RegisterArrowReaderZeroCopy(name string, reader array.RecordReader) error
func (*Connection) RegisterFFITableProvider ¶ added in v0.530100.2
func (conn *Connection) RegisterFFITableProvider(name string, provider unsafe.Pointer, providerDataFusionVersion string) error
RegisterFFITableProvider registers a foreign datafusion-ffi FFI_TableProvider (produced by another library) under name. provider must point to a valid FFI_TableProvider; the callee clones it, so the caller retains ownership of the pointer. providerDataFusionVersion is the datafusion version the producing library reports, checked before the provider is dereferenced. The producing library must outlive every registration, dependent query/view, stream, and returned batch, which may retain foreign callbacks after deregistration. See datafusion.RegisterFFITableProvider for the full contract.
func (*Connection) RegisterGo ¶ added in v0.550100.0
func (conn *Connection) RegisterGo(name string, object any, kind int) error
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func OpenDatabase ¶
type DateParameter ¶
type DateParameter struct {
Days int32
}
type DecimalParameter ¶
type DiscoverableCatalogProvider ¶ added in v0.550100.1
type DiscoverableCatalogProvider interface {
CatalogProvider
SchemaNames(ctx context.Context) ([]string, error)
TableNames(ctx context.Context, schema string) ([]string, error)
}
DiscoverableCatalogProvider optionally lists schemas and tables for SQL metadata queries. Names are literal identifiers, not SQL fragments. Listings are refreshed for each metadata query; ordinary table queries only resolve referenced tables. Implementations must support concurrent calls and honor ctx. A nil list is empty. Duplicate names are ignored; empty/NUL names are errors. The reserved information_schema schema is supplied by DataFusion.
type DurationParameter ¶
type DurationParameter struct {
Nanoseconds int64
}
type Error ¶
func (*Error) NativeErrorKind ¶
type Expr ¶ added in v0.550100.0
type Expr interface {
// contains filtered or unexported methods
}
Expr is a filter predicate pushed down to a PushdownTableProvider. It is a closed, bounded AST: the engine only ever pushes column-vs-literal comparisons, IS [NOT] NULL, [NOT] BETWEEN, [NOT] IN, and AND/OR/NOT combinations of those. Predicates outside these forms (functions, casts, arithmetic, LIKE, ...) are never pushed down; the engine evaluates them after the scan.
The concrete types are Compare, IsNull, Between, InList, And, Or, and Not. Providers pattern-match with a type switch:
switch e := expr.(type) {
case datafusion.Compare:
// e.Column, e.Op, e.Literal
}
type Import ¶ added in v0.550100.0
type Import struct {
// contains filtered or unexported fields
}
Import owns unpublished native batches. Close also aborts an unfinished import.
func (*Import) Commit ¶ added in v0.550100.0
func (i *Import) Commit(conn *Connection) error
type InsertOp ¶ added in v0.550100.0
type InsertOp int
InsertOp describes a requested write. Providers must reject unsupported modes.
type IsNull ¶ added in v0.550100.0
IsNull is an IS NULL test on a column; Negated makes it IS NOT NULL.
type Literal ¶ added in v0.550100.0
type Literal struct {
Type LiteralType
Value any
Unit TimeUnit
TimeZone string
}
Literal is a typed literal value in a pushed-down predicate. Value holds the Go representation determined by Type:
LiteralBool bool LiteralInt8 int8 (int16/int32/int64 accordingly) LiteralUint8 uint8 (uint16/uint32/uint64 accordingly) LiteralFloat32 float32 (float64 accordingly) LiteralUtf8 string LiteralBinary []byte LiteralDate32 int32 (days since the Unix epoch) LiteralDate64 int64 (milliseconds since the Unix epoch) LiteralTimestamp int64 (in Unit since the Unix epoch)
Unit and TimeZone are set only for LiteralTimestamp; TimeZone may be empty for a timezone-less timestamp.
func (*Literal) UnmarshalJSON ¶ added in v0.550100.0
UnmarshalJSON decodes the wire representation of a literal, e.g. {"type":"int64","value":2} or {"type":"timestamp","value":1700000000,"unit":"s","tz":"UTC"}.
type LiteralType ¶ added in v0.550100.0
type LiteralType string
LiteralType identifies the type of a literal value in a pushed-down predicate.
const ( LiteralBool LiteralType = "bool" LiteralInt8 LiteralType = "int8" LiteralInt16 LiteralType = "int16" LiteralInt32 LiteralType = "int32" LiteralInt64 LiteralType = "int64" LiteralUint8 LiteralType = "uint8" LiteralUint16 LiteralType = "uint16" LiteralUint32 LiteralType = "uint32" LiteralUint64 LiteralType = "uint64" LiteralFloat32 LiteralType = "float32" LiteralFloat64 LiteralType = "float64" LiteralUtf8 LiteralType = "utf8" LiteralBinary LiteralType = "binary" LiteralDate32 LiteralType = "date32" LiteralDate64 LiteralType = "date64" LiteralTimestamp LiteralType = "timestamp" )
type NullParameter ¶
type NullParameter struct {
Type ParameterType
Precision uint8
Scale int8
TimeZone string
}
type ParameterType ¶
type ParameterType int32
const ( ParameterBool ParameterType = iota + 1 ParameterInt64 ParameterUInt64 ParameterFloat64 ParameterString ParameterBinary ParameterDate ParameterTime ParameterTimestamp ParameterDuration ParameterDecimal )
type PushdownTableProvider ¶ added in v0.550100.0
type PushdownTableProvider interface {
TableProvider
ScanWithOptions(context.Context, ScanOptions) (array.RecordReader, error)
}
PushdownTableProvider optionally accepts projection and conservative pruning. It must return precisely the projected schema, including field order.
type RecordReader ¶ added in v0.550000.2
RecordReader owns a native result stream. Its schema is available before the first read, including for empty results. Close is idempotent and cancels work. Each returned batch has its own reference and must be released by the caller.
type ScalarFunction ¶ added in v0.550100.0
type ScalarFunction struct {
Name string
Arguments []arrow.DataType
ReturnType arrow.DataType
Volatility Volatility
Evaluate func(ctx context.Context, args []arrow.Array, rows int) (arrow.Array, error)
}
ScalarFunction is a typed, batch-oriented Go function. Evaluate owns its returned array; the bridge releases it. Arguments are borrowed for the call. rows is supplied separately so zero-argument functions can produce a batch. Calls may run concurrently. Blocking implementations must honor ctx.
type ScanOptions ¶ added in v0.550100.0
ScanOptions describes exact projection and advisory pruning. A nil Projection means all columns; an empty non-nil slice means zero columns, preserving rows. Filters are ANDed and rechecked by DataFusion. Limit is -1 without a safe hint.
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
func (*Statement) ExecuteArrow ¶
func (stmt *Statement) ExecuteArrow(ctx context.Context, args []driver.NamedValue) (RecordReader, error)
func (*Statement) Serializes ¶
type TableProvider ¶ added in v0.550100.0
type TableProvider interface {
Schema() *arrow.Schema
Scan(context.Context) (array.RecordReader, error)
}
TableProvider supplies an independent reader for each scan. Readers transfer ownership to the engine; buffers are copied before native code retains them. Implementations must support concurrent calls and honor context cancellation.
type TimeParameter ¶
type TimeParameter struct {
Nanoseconds int64
}
type TimeUnit ¶ added in v0.550100.0
type TimeUnit string
TimeUnit is the resolution of a timestamp literal.
type TimestampParameter ¶
type UInt64Parameter ¶
type UInt64Parameter struct {
Value uint64
}
type Volatility ¶ added in v0.550100.0
type Volatility int
Volatility controls optimizer assumptions for an explicitly registered UDF.
const ( Volatile Volatility = iota // default: every call may return a different value Stable // identical arguments produce identical values within one query Immutable // identical arguments always produce identical values )
type WritableTableProvider ¶ added in v0.550100.0
type WritableTableProvider interface {
TableProvider
InsertInto(context.Context, InsertOp, array.RecordReader) (uint64, error)
}
WritableTableProvider can consume INSERT input. The reader is borrowed for this call and released by the bridge. Retain batches to keep them beyond the call. Implementations must check reader.Err(), honor cancellation, and finish their commit/rollback before returning. Errors are never retried by the bridge.