You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-21Lines changed: 54 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,16 @@
1
1
# Apache Drill dialect for SQLAlchemy.
2
+
2
3
---
4
+
3
5
The primary purpose of this is to have a working dialect for Apache Drill that can be used with Apache Superset.
4
6
5
7
https://superset.incubator.apache.org
6
8
7
-
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.
9
+
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.
8
10
9
-
## Installation
10
-
Installing the dialect is straightforward. Simply:
11
+
## Installation
12
+
13
+
Installing the dialect is straightforward. Simply:
To connect to Drill running on a local machine running in embedded mode you can use the following connection string.
33
+
To connect to Drill running on a local machine running in embedded mode you can use the following connection string.
34
+
30
35
```
31
36
drill+sadrill://localhost:8047/dfs?use_ssl=False
32
37
```
33
38
39
+
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.
40
+
```python
41
+
r = engine.execute('select current_timestamp')
42
+
r.cursor.result_md # access metadata, but only leading metadata
43
+
cur = r.cursor # obtain a reference for use later
44
+
r.fetchall() # iterate through all result data
45
+
cur.result_md # access metadata, including trailing metadata
46
+
del cur # optionally delete the reference when done
47
+
```
48
+
49
+
### Changes in Drill 1.19 affecting drill+sadrill
50
+
51
+
In versions of Drill earlier than 1.19, all data values are serialised to JSON strings and column type metadata comes after the data itself. As a result, for these versions of Drill, the drill+sadrill dialect returns every data value as a string. To convert non-string data to its native type you need to typecast it yourself.
52
+
53
+
In Drill 1.19 the REST API began making use of numeric types in JSON for numbers and times, the latter via a UNIX time representation. As a result, the drill+sadrill dialect is able to return appropriate types for numbers and times when used with Drill >= 1.19.
54
+
34
55
## Usage with JDBC
56
+
35
57
Connecting to Drill via JDBC is a little more complicated than a local installation and complete instructions can be found on the Drill documentation here: https://drill.apache.org/docs/using-the-jdbc-driver/.
36
58
37
59
In order to configure SQLAlchemy to work with Drill via JDBC you must:
38
-
* Download the latest JDBC Driver available here: http://apache.osuosl.org/drill/
39
-
* Copy this driver to your classpath or other known path
40
-
* Set an environment variable called `DRILL_JDBC_DRIVER_PATH` to the full path of your driver location
41
-
* Set an environment variable called `DRILL_JDBC_JAR_NAME` to the name of the `.jar` file for the Drill driver.
42
60
43
-
Additionally, you will need to install `JayDeBeApi` as well as jPype version 0.6.3.
44
-
These modules are listed as optional dependencies and will not be installed by the default installer.
61
+
- Download the latest JDBC Driver available here: http://apache.osuosl.org/drill/
62
+
- Copy this driver to your classpath or other known path
63
+
- Set an environment variable called `DRILL_JDBC_DRIVER_PATH` to the full path of your driver location
64
+
- Set an environment variable called `DRILL_JDBC_JAR_NAME` to the name of the `.jar` file for the Drill driver.
65
+
66
+
Additionally, you will need to install `JayDeBeApi` as well as jPype version 0.6.3.
67
+
These modules are listed as optional dependencies and will not be installed by the default installer.
45
68
46
69
If the JDBC driver is not available, the dialect will throw errors when trying
47
70
to connect. In addition, sqlalchemy-drill will not launch a JVM for you so you
or for the case when you have DSN configured in `odbc.ini`:
112
+
82
113
```
83
114
drill+odbc:///?DSN=drill_dsn_name
84
115
```
85
116
86
117
**Note:** it's better to avoid using connection string with `hostname:port` or `username`/`password`, like 'drill+odbc://admin:password@localhost:31010/' but use only ODBC properties instead to avoid any misinterpretation between these parameters.
87
118
88
-
89
119
## Usage with Superset
90
-
For a complete tutorial on how to use Superset with Drill, read the tutorial on @cgivre's blog available here: http://thedataist.com/visualize-anything-with-superset-and-drill/.
91
120
121
+
For a complete tutorial on how to use Superset with Drill, read the tutorial on @cgivre's blog available here: http://thedataist.com/visualize-anything-with-superset-and-drill/.
92
122
93
123
## Current Status/Development Approach
124
+
94
125
Currently we can connect to drill, and issue queries for most visualizations and get results. We also enumerate table columns for some times of tables. Here are things that are working as some larger issues to work out. (Individual issues are tracked under issues)
95
126
96
-
* Connection to Drill via the databases tab in Superset succeeds
97
-
* You can do basic queries for most types of viz/tables
98
-
* There may be issues with advanced queries/joins. As you learn about new ones, please track in issues
127
+
- Connection to Drill via the databases tab in Superset succeeds
128
+
- You can do basic queries for most types of viz/tables
129
+
- There may be issues with advanced queries/joins. As you learn about new ones, please track in issues
99
130
100
131
### Many thanks
101
-
to drillpy and pydrill for code used in creating the `drilldbapi.py` code for connecting!
102
132
103
-
### Docker
133
+
to drillpy and pydrill for code used in creating the original `drilldbapi.py` code for connecting!
134
+
135
+
### Docker
136
+
104
137
It is recommended to extend [the official Docker image](https://hub.docker.com/r/apache/superset) to include this Apache Drill driver:
0 commit comments