Presto ODBC Driver
ODBC is a C API that provides a standard way of communicating with anything that accepts SQL-like input; the Presto ODBC Driver lets you communicate with Presto via this standard. The high-level goal is to be able to communicate with Presto from MS Query, MS Excel, and Tableau.
This driver is written in the D Programming Language
- Only works on Windows
- Many functions are not implemented, the driver does not meet the "Core" level of ODBC conformance
- The only error handling in place is a "catch and log" strategy
- Most queries will work as expected
- Tableau works correctly for the cases we have tried
- MS Query is partially tested and may work if you create a Presto File DSN
- The driver is single-threaded
- You cannot run multiple instances of the driver on the same machine due to limitations in D's support for DLLs
- Full ODBC 3.51 conformance
- Full support on Windows/Mac/Linux
- Seamless integration with Tableau
- Cygwin with the GNU make package
- MSVC 64-bit linker (download and install the free Express 2013 edition for Windows Desktop)
- dmd (D Language Compiler), tested with dmd 2.065 (note: this must be the installer version and it must be installed after Visual Studio)
- Access to a running Presto instance
- Build the Presto ODBC Driver
- Launch the Cygwin terminal
- Navigate to your checkout of this repo (e.g.
cd /cygdrive/c/presto-odbc) make clean install-- builds the driver, runs tests, copies the driver and libcurl toC:\tempand backs up the log files- Register the Presto ODBC Driver by double clicking the
register_driver.regfile in the main directory of this repo - Setup a data source for the driver
- Open Control Panel and choose
Set up ODBC data sources (64-bit) - Sanity Check: Look at the
Driverstab, make sure you seePresto ODBC Driver - Enable the Driver Manager Logfile (from the ODBC Data Sources window)
1. Go to the
Tracingtab 1. Set theLog File PathtoC:\temp\SQL.LOG1. ClickStart Tracing Now1. Click Ok to close the program
- Open Tableau
- Click
Connect to data - At the bottom, select
Other Database (ODBC) - Click the radio button for
Driver - Select
Presto ODBC Driver - Click
Connect - Enter a connection parameters string of the form
key=value;key=valueto describe your connection. A description of the supported keys and values can be found in the Connection Parameters file - Tableau will then partially load the driver and redundantly ask for the same information in Tableau's UI:
1. Replace the contents of the
String Extrasbox with the string you entered in notepad. Ignore the rest. 1. ClickOK - Tableau will perform a bunch of fake queries to analyze the ODBC driver, this may take a while to complete but only needs to happen once
- On the new screen:
- Click
Select Schema, then press the search icon, then select the schema you entered on the previous screen - Search for
tables(or press enter to see all of them) and drag any table you wish to use to the right - Click
Go to Worksheet - Click
OKto go past the warning dialog - Analyze!
Not all of the conventions have been applied to the source yet.
- 4 space indentation
- Try to limit to 120 columns
- Prefer
myHttpFunctiontomyHTTPFunction - All ODBC functions must have their contents wrapped with a call to
exceptionBoundary - As appropriate, change integer types to enum types (use
StatementAttributeinstead ofSQLSMALLINT, etc) - Always wrap C types with safer D abstractions (see
toDStringandOutputWChar); prefix the C-style variables with an underscore - Also prefix variables with an underscore to express that the variable should be cast/converted to or encapsulated in another type before use
- Use
dllEnforceinstead ofassert - Avoid fully qualifying enum values (
MyEnumType.MyEnumValue); use awithstatement instead - Always use a
withstatement when accessing ODBC handles - Always specify whether lengths are in bytes or characters as part of a variable's name
- At the top of the file, separate
imports from different packages with a blank line. In particular, there should be a blank line between imports fromstdandpresto.clientas well as betweenpresto.clientandpresto.driver - Always group imports from the same packages together