ODBC Data Wrapper Reference
ODBC HeavyConnect and import is currently a beta feature.
This topic provides setup and configuration details and information about supported data types when using ODBC HeavyConnect or import. This reference also describes ODBC data wrapper assumptions and supported mappings of HeavyDB column types to ODBC column types, and provides RDMS-specific notes.
ODBC Driver Installation
To HeavyConnect to or import from an external RDMS using the ODBC data wrapper, make sure that an appropriate ODBC driver is installed for the RDMS you want to access. RDMS vendors websites usually provide ODBC driver download and configuration instructions, and in certain cases, ODBC drivers are managed by third-party vendors that provide these instructions.
ODBC Configuration Files
Two key configuration files need to be set up when using ODBC HeavyConnect or import: odbcinst.ini and odbc.ini.
The odbcinst.ini file specifies a list of installed drivers, along with required configuration for those drivers (the path to the driver binary). The following example is an odbcinst.ini configuration file for an instance with installed drivers for PostGreSQL, Redshift, and Snowflake:
Use an intuitive name for the drivers, such as the official name of the RDMS, so that users can easily know the driver names to use in connection strings.
The odbc.ini file contains configuration for database-specific connections. Each connection configuration is identified by a data source name (DSN). The following example is an odbc.ini file with configuration for the default postgres database on a local instance of PostgreSQL running on port 5432:
Locate odbcinst.ini and odbc.ini in the /etc/ directory, or in the home directory for cases where the server process is started under a specific user account.
The PostgreSQL unicode ODBC driver is currently not supported.
Setting Up ODBC Connectors for Heavy Immerse
In certain cases, an odbcinst.ini configuration file that omits the [ODBC Drivers] section is automatically generated when ODBC drivers (such as the PostgreSQL driver) are installed. This section of the configuration file is required for the ODBC-related connectors to appear in Heavy Immerse.
In addition, the driver names specified in odbcinst.ini must match the RDMS name for connectors to appear in Immerse. Specifically, the driver name should be PostgreSQL for PostgreSQL, Redshift for AWS Redshift, and Snowflake for Snowflake.
Working with HEAVY.AI Docker Images
For docker deployments of HEAVY.AI, ODBC driver installations can be managed in a Dockerfile that uses the HEAVY.AI Docker image as a base. For example, you can create a docker image with installed PostGreSQL, Redshift, and Snowflake ODBC drivers using a Dockerfile with the following content.
Always consult the license and terms and conditions of the ODBC drivers you install. The examples here are provided for illustrative purposes only.
You can then build a new image with installed ODBC drivers using the Dockerfile.
The odbcinst.ini and odbc.ini configuration files should be bound to /etc/odbcinst.ini and /etc/odbc.ini, respectively, when running the container.
ODBC Data Wrapper Assumptions
- The remote database management system supports the MIN, MAX, and LENGTH SQL functions. These functions are used internally for optimizations and validations.
- The combination of the query specified in the foreign table’s SQL_SELECT option and the SQL___ORDER_BY option is guaranteed to return a result set in the same order every time the query is executed.
- Queries for geo columns are always returned as WKT strings. This implies that either geo columns are stored as text columns containing WKT strings, geo columns are cast to text (for example, using a function like ST_AsText) in the SQL_SELECT query, or the remote database management system, by default, projects geo columns as WKT strings.
HeavyDB to ODBC Data Type Mapping
Numeric and Boolean Types
*[1] PostgreSQL requires setting the option BoolsAsChar=false to represent boolean columns as SQL_BIT.
Date and Time Types
Geo and String Types
Array Type
Array data types currently are not supported.
See https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/sql-data-types for more details about ODBC data types, and consult the specific RDMS ODBC driver documentation for details about how the RDMS data types map to the ODBC data types.
RDMS-Specific Notes
PostgreSQL
- The official PostgreSQL ODBC driver can be downloaded from https://odbc.postgresql.org/
- Accessing BOOLEAN data in PostgreSQL requires the
BoolsAsChar=falseoption to be added to the connection string or DSN configuration.
Google BigQuery
- The official BigQuery ODBC data connector installation and configuration guide can be downloaded from https://cloud.google.com/bigquery/docs/reference/odbc-jdbc-drivers.
- The BigQuery ODBC connector uses the OAuth 2.0 protocol for authentication; steps are provided by the official installation guide.
- In all authentication methods, the Principal member (e.g. Service Account, User Account) must have at least a
roles/bigquery.dataViewerpermission grant on the GCP project. - Using a Service Account is the recommended method for authentication. Steps are provided in “Using a Google Service Account” in the installation guide.
- If you are using a User Account for authentication, some steps may be missing from the installation guide in the “Using a Google User Account” section. Include the following steps:
- Before starting a Client ID & Secret must be created, from the GCP console select
APIs & Services > Credentials > Create Credentials > OAuth Client ID > Web Application to create one. The URI https://developers.google.com/oauthplayground must be added to the list of Authorized redirect URIs. - Before clicking the Authorize APIs button on the https://developers.google.com/oauthplayground webpage, click the “OAuth 2.0 Configuration” icon to reveal a menu; check the Use your own OAuth credentials box to reveal additional options; and specify the Client ID & Secret provided by the previous addendum step.
- While on the Selecting & authorize APIs section of the https://developers.google.com/oauthplayground webpage, ensure that the BigQuery API v2 > https://www.googleapis.com/auth/bigquery option is selected.
- Before starting a Client ID & Secret must be created, from the GCP console select
- In all authentication methods, the Principal member (e.g. Service Account, User Account) must have at least a