Apache Drill for SQLAlchemy
Maintained. Last release 10 months ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install sqlalchemy-drillApache Drill dialect for SQLAlchemy.
The primary purpose of this is to have a working dialect for Apache Drill that can be used with Apache Superset.
https://superset.incubator.apache.org
Obviously, a working, robust dialect for Drill serves other purposes as well, but most of the iterative planning for this REPO will be based on working with Superset. Other changes will gladly be incorporated, as long as it doesn't hurt Superset integration.
Installation
Installing the dialect is straightforward. Simply:
pip install sqlalchemy-drill
Alternatively, you can download the latest release from github and install from here:
python3 -m pip install git+https://github.com/JohnOmernik/sqlalchemy-drill.git
Usage with REST
Drill's REST API can execute queries with results streamed to JSON returned over chunked HTTP for Drill >= 1.19, otherwise with results buffered and then returned in a conventional HTTP response. A SQLAlchemy URL to connect to Drill over REST looks like the following.
drill+sadrill://<username>:<password>@<host>:<port>/<storage_plugin>?use_ssl=True
To connect to Drill running on a local machine running in embedded mode you can use the following connection string.
drill+sadrill://localhost:8047/dfs?use_ssl=False
Supported URL query parameters
| Parameter | Type | Description |
|---|---|---|
| use_ssl | boolean | Whether to connect to Drill using HTTPS |
| verify_ssl | boolean | Whether to verify the server's TLS certificate |
| impersonation_target[1] | string | Username of a Drill user to be impersonated by this connection |
[1] Requires a build of Drill that incorporates the fix for DRILL-8168.
Trailing metadata
Query result metadata returned by the Drill REST API is stored in the result_md field of the DB-API Cursor object. Note that any trailing metadata, i.e. metadata which comes after result row data, will only be populated after you have iterated through all of the returned rows. If you need this trailing metadata you can make the cursor object reachable after it has been completely iterated by obtaining a reference to it beforehand, as follows.
r = engine.execute('select current_timestamp')
r.cursor.result_md # access metadata, but only leading metadata
cur = r.cursor # obtain a reference for use later
r.fetchall() # iterate through all result data
cur.result_md # access metadata, including trailing metadata
del cur # optionally delete the reference when done