presto-go-client: github.com/prestodb/presto-go-client/presto Index | Files

package presto

import "github.com/prestodb/presto-go-client/presto"

Package presto provides a database/sql driver for Facebook's Presto.

The driver should be used via the database/sql package:

import "database/sql"
import _ "github.com/prestodb/presto-go-client/presto"

dsn := "http://user@localhost:8080?catalog=default&schema=test"
db, err := sql.Open("presto", dsn)

Index

Package Files

presto.go serial.go

Constants

const (
    KerberosEnabledConfig = "KerberosEnabled"

    SSLCertPathConfig = "SSLCertPath"
)

Variables

var (
    // DefaultQueryTimeout is the default timeout for queries executed without a context.
    DefaultQueryTimeout = 60 * time.Second

    // DefaultCancelQueryTimeout is the timeout for the request to cancel queries in presto.
    DefaultCancelQueryTimeout = 30 * time.Second

    // ErrOperationNotSupported indicates that a database operation is not supported.
    ErrOperationNotSupported = errors.New("presto: operation not supported")

    // ErrQueryCancelled indicates that a query has been cancelled.
    ErrQueryCancelled = errors.New("presto: query cancelled")
)

func DeregisterCustomClient Uses

func DeregisterCustomClient(key string)

DeregisterCustomClient removes the client associated to the key.

func RegisterCustomClient Uses

func RegisterCustomClient(key string, client *http.Client) error

RegisterCustomClient associates a client to a key in the driver's registry.

Register your custom client in the driver, then refer to it by name in the DSN, on the call to sql.Open:

foobarClient := &http.Client{
	Transport: &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
			DualStack: true,
		}).DialContext,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
		TLSClientConfig:       &tls.Config{
		// your config here...
		},
	},
}
presto.RegisterCustomClient("foobar", foobarClient)
db, err := sql.Open("presto", "https://user@localhost:8080?custom_client=foobar")

func Serial Uses

func Serial(v interface{}) (string, error)

Serial converts any supported value to its equivalent string for as a presto parameter See https://prestodb.io/docs/current/language/types.html

type Config Uses

type Config struct {
    PrestoURI          string            // URI of the Presto server, e.g. http://user@localhost:8080
    Source             string            // Source of the connection (optional)
    Catalog            string            // Catalog (optional)
    Schema             string            // Schema (optional)
    SessionProperties  map[string]string // Session properties (optional)
    CustomClientName   string            // Custom client name (optional)
    KerberosEnabled    string            // KerberosEnabled (optional, default is false)
    KerberosKeytabPath string            // Kerberos Keytab Path (optional)
    KerberosPrincipal  string            // Kerberos Principal used to authenticate to KDC (optional)
    KerberosRealm      string            // The Kerberos Realm (optional)
    KerberosConfigPath string            // The krb5 config path (optional)
    SSLCertPath        string            // The SSL cert path for TLS verification (optional)
}

Config is a configuration that can be encoded to a DSN string.

func (*Config) FormatDSN Uses

func (c *Config) FormatDSN() (string, error)

FormatDSN returns a DSN string from the configuration.

type Conn Uses

type Conn struct {
    // contains filtered or unexported fields
}

Conn is a presto connection.

func (*Conn) Begin Uses

func (c *Conn) Begin() (driver.Tx, error)

Begin implements the driver.Conn interface.

func (*Conn) Close Uses

func (c *Conn) Close() error

Close implements the driver.Conn interface.

func (*Conn) Prepare Uses

func (c *Conn) Prepare(query string) (driver.Stmt, error)

Prepare implements the driver.Conn interface.

func (*Conn) PrepareContext Uses

func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

PrepareContext implements the driver.ConnPrepareContext interface.

type ErrQueryFailed Uses

type ErrQueryFailed struct {
    StatusCode int
    Reason     error
}

ErrQueryFailed indicates that a query to presto failed.

func (*ErrQueryFailed) Error Uses

func (e *ErrQueryFailed) Error() string

Error implements the error interface.

type NullMap Uses

type NullMap struct {
    Map   map[string]interface{}
    Valid bool
}

NullMap represents a map type that may be null.

func (*NullMap) Scan Uses

func (m *NullMap) Scan(v interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice2Bool Uses

type NullSlice2Bool struct {
    Slice2Bool [][]sql.NullBool
    Valid      bool
}

NullSlice2Bool represents a two-dimensional slice of bool that may be null.

func (*NullSlice2Bool) Scan Uses

func (s *NullSlice2Bool) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice2Float64 Uses

type NullSlice2Float64 struct {
    Slice2Float64 [][]sql.NullFloat64
    Valid         bool
}

NullSlice2Float64 represents a two-dimensional slice of float64 that may be null.

func (*NullSlice2Float64) Scan Uses

func (s *NullSlice2Float64) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice2Int64 Uses

type NullSlice2Int64 struct {
    Slice2Int64 [][]sql.NullInt64
    Valid       bool
}

NullSlice2Int64 represents a two-dimensional slice of int64 that may be null.

func (*NullSlice2Int64) Scan Uses

func (s *NullSlice2Int64) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice2Map Uses

type NullSlice2Map struct {
    Slice2Map [][]NullMap
    Valid     bool
}

NullSlice2Map represents a two-dimensional slice of NullMap that may be null.

func (*NullSlice2Map) Scan Uses

func (s *NullSlice2Map) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice2String Uses

type NullSlice2String struct {
    Slice2String [][]sql.NullString
    Valid        bool
}

NullSlice2String represents a two-dimensional slice of string that may be null.

func (*NullSlice2String) Scan Uses

func (s *NullSlice2String) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice2Time Uses

type NullSlice2Time struct {
    Slice2Time [][]NullTime
    Valid      bool
}

NullSlice2Time represents a two-dimensional slice of time.Time that may be null.

func (*NullSlice2Time) Scan Uses

func (s *NullSlice2Time) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice3Bool Uses

type NullSlice3Bool struct {
    Slice3Bool [][][]sql.NullBool
    Valid      bool
}

NullSlice3Bool implements a three-dimensional slice of bool that may be null.

func (*NullSlice3Bool) Scan Uses

func (s *NullSlice3Bool) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice3Float64 Uses

type NullSlice3Float64 struct {
    Slice3Float64 [][][]sql.NullFloat64
    Valid         bool
}

NullSlice3Float64 represents a three-dimensional slice of float64 that may be null.

func (*NullSlice3Float64) Scan Uses

func (s *NullSlice3Float64) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice3Int64 Uses

type NullSlice3Int64 struct {
    Slice3Int64 [][][]sql.NullInt64
    Valid       bool
}

NullSlice3Int64 implements a three-dimensional slice of int64 that may be null.

func (*NullSlice3Int64) Scan Uses

func (s *NullSlice3Int64) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice3Map Uses

type NullSlice3Map struct {
    Slice3Map [][][]NullMap
    Valid     bool
}

NullSlice3Map represents a three-dimensional slice of NullMap that may be null.

func (*NullSlice3Map) Scan Uses

func (s *NullSlice3Map) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice3String Uses

type NullSlice3String struct {
    Slice3String [][][]sql.NullString
    Valid        bool
}

NullSlice3String implements a three-dimensional slice of string that may be null.

func (*NullSlice3String) Scan Uses

func (s *NullSlice3String) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSlice3Time Uses

type NullSlice3Time struct {
    Slice3Time [][][]NullTime
    Valid      bool
}

NullSlice3Time represents a three-dimensional slice of time.Time that may be null.

func (*NullSlice3Time) Scan Uses

func (s *NullSlice3Time) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSliceBool Uses

type NullSliceBool struct {
    SliceBool []sql.NullBool
    Valid     bool
}

NullSliceBool represents a slice of bool that may be null.

func (*NullSliceBool) Scan Uses

func (s *NullSliceBool) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSliceFloat64 Uses

type NullSliceFloat64 struct {
    SliceFloat64 []sql.NullFloat64
    Valid        bool
}

NullSliceFloat64 represents a slice of float64 that may be null.

func (*NullSliceFloat64) Scan Uses

func (s *NullSliceFloat64) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSliceInt64 Uses

type NullSliceInt64 struct {
    SliceInt64 []sql.NullInt64
    Valid      bool
}

NullSliceInt64 represents a slice of int64 that may be null.

func (*NullSliceInt64) Scan Uses

func (s *NullSliceInt64) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSliceMap Uses

type NullSliceMap struct {
    SliceMap []NullMap
    Valid    bool
}

NullSliceMap represents a slice of NullMap that may be null.

func (*NullSliceMap) Scan Uses

func (s *NullSliceMap) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSliceString Uses

type NullSliceString struct {
    SliceString []sql.NullString
    Valid       bool
}

NullSliceString represents a slice of string that may be null.

func (*NullSliceString) Scan Uses

func (s *NullSliceString) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullSliceTime Uses

type NullSliceTime struct {
    SliceTime []NullTime
    Valid     bool
}

NullSliceTime represents a slice of time.Time that may be null.

func (*NullSliceTime) Scan Uses

func (s *NullSliceTime) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type NullTime Uses

type NullTime struct {
    Time  time.Time
    Valid bool
}

NullTime represents a time.Time value that can be null. The NullTime supports presto's Date, Time and Timestamp data types, with or without time zone.

func (*NullTime) Scan Uses

func (s *NullTime) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

type Numeric Uses

type Numeric string

Numeric is a string representation of a number, such as "10", "5.5" or in scientific form If another string format is used it will error to serialise

type UnsupportedArgError Uses

type UnsupportedArgError struct {
    // contains filtered or unexported fields
}

func (UnsupportedArgError) Error Uses

func (e UnsupportedArgError) Error() string

Package presto imports 23 packages (graph) and is imported by 4 packages. Updated 2019-12-20. Refresh now. Tools for package owners.