impalathing

package module
v0.0.0-...-490765f Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: MIT Imports: 11 Imported by: 0

README

go-impala is a Go driver for Cloudera Impala

It's based on impalathing

Using

package main

import (
    "log"
    "fmt"
    "time"
    impalathing "github.com/bippio/go-impala"
)

func main() {
    host := "<impala-host>"
    port := 21000

    opts := impalathing.DefaultOptions

    // enable LDAP authentication:
    opts.UseLDAP = true
    opts.Username = "<username>"
    opts.Password = "<password>"

    con, err := impalathing.Connect(host, port, &opts)
    if err != nil {
        log.Fatal(err)
    }

    query, err := con.Query(context.Background(), "<sql-query>")

    startTime := time.Now()
    results := query.FetchAll(context.Background())
    log.Printf("Fetch %d rows(s) in %.2fs", len(results), time.Duration(time.Since(startTime)).Seconds())
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultOptions = Options{PollIntervalSeconds: 0.1, BatchSize: 10000, BufferSize: 4096}
)

Functions

This section is empty.

Types

type ColumnSchema

type ColumnSchema struct {
	Name string
	Type string
}

type Connection

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

func Connect

func Connect(host string, port int, options *Options) (*Connection, error)

func (*Connection) Close

func (c *Connection) Close(ctx context.Context) error

func (*Connection) Query

func (c *Connection) Query(ctx context.Context, query string) (RowSet, error)

type Options

type Options struct {
	UseLDAP             bool
	Username            string
	Password            string
	PollIntervalSeconds float64
	BatchSize           int64
	BufferSize          int
}

type RowSet

type RowSet interface {
	Schema(ctx context.Context) []*ColumnSchema
	Next(ctx context.Context) bool
	Scan(dest ...interface{}) error
	Poll(ctx context.Context) (*Status, error)
	Wait(ctx context.Context) (*Status, error)
	FetchAll(ctx context.Context) []map[string]interface{}
	MapScan(dest map[string]interface{}) error
}

A RowSet represents an asyncronous hive operation. You can Reattach to a previously submitted hive operation if you have a valid thrift client, and the serialized Handle() from the prior operation.

type Status

type Status struct {
	Error error
	// contains filtered or unexported fields
}

Represents job status, including success state and time the status was updated.

func (*Status) IsComplete

func (s *Status) IsComplete() bool

func (*Status) IsSuccess

func (s *Status) IsSuccess() bool

Jump to

Keyboard shortcuts

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