GithubHelp home page GithubHelp logo

plusplusjiajia / dremio-flight-connector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dremio-hub/dremio-flight-connector

0.0 1.0 0.0 144 KB

Dremio Flight connector. Access Dremio using Arrow flight

License: Apache License 2.0

Java 98.32% Dockerfile 1.68%

dremio-flight-connector's Introduction

Dremio Flight Connector

Build Status

Building and Installation

  1. In root directory with the pom.xml file run mvn clean install
  2. Take the resulting shaded jar dremio-flight-connector-{VERSION}-shaded.jar file in the target folder and put it in the \dremio\jars folder in Dremio
  3. Restart Dremio

Configuration

SSL

  • ensure you have ssl set up in your dremio.conf. This plugin currently uses the same certificates as the webserver.
  • set property -Ddremio.flight.use-ssl=true

Hostname & port

  • set property -Ddremio.flight.port=47470 to change the port. Defaults to 47470
  • set property -Ddremio.flight.host=localhost to change the host/listening interface. Particularly useful if you are accessing remotely or generating ssl certs

Accessing Dremio via flight in python

The Flight endpoint is exposed on port 47470. The most recent release of pyarrow (0.15.0) has the flight client built in. To access Dremio via Flight first install pyarrow (conda install pyarrow -c conda-forge or pip install pyarrow). Then use the dremio-client to access flight. Alternatively use:

from pyarrow import flight
import pyarrow as pa

class HttpDremioClientAuthHandler(flight.ClientAuthHandler):

    def __init__(self, username, password):
        super(flight.ClientAuthHandler, self).__init__()
        self.basic_auth = flight.BasicAuth(username, password)
        self.token = None

    def authenticate(self, outgoing, incoming):
        auth = self.basic_auth.serialize()
        outgoing.write(auth)
        self.token = incoming.read()

    def get_token(self):
        return self.token

username = '<USERNAME>'
password = '<PASSWORD>'
sql = '''<SQL_QUERY>'''

client = flight.FlightClient('grpc+tcp://<DREMIO_COORDINATOR_HOST>:47470')
client.authenticate(HttpDremioClientAuthHandler(username, password)) 
info = client.get_flight_info(flight.FlightDescriptor.for_command(sql))
reader = client.do_get(info.endpoints[0].ticket)
batches = []
while True:
    try:
        batch, metadata = reader.read_chunk()
        batches.append(batch)
    except StopIteration:
        break
data = pa.Table.from_batches(batches)
df = data.to_pandas()

Notes:

  • the Command protobuf object has been removed to reduce dependencies

dremio-flight-connector's People

Contributors

rymurr avatar acryljonny avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.