Starburst IBM DB2 connector#
The IBM DB2 connector allows querying and creating tables in an external DB2 database.
Requirements#
To connect to IBM DB2, you need:
DB2 11.5 or higher for Linux, Unix, and Windows (LUW).
Network access from the coordinator and workers to the DB2 server. Port 51000 is the default port.
A valid Starburst Enterprise license.
Configuration#
Any of the below installation and configuration methods require the following artifacts:
DB2 JDBC driver file
db2jcc-db2jcc4.jar
obtained from IBMJDBC connection details to connect to DB2 in a catalog properties file (e.g.
db2.properties
for a catalog nameddb2
). File should contain the following contents, replacing the connection properties as appropriate for your setup:
connector.name=db2
connection-url=jdbc:db2://HOST:PORT/DATABASE
connection-user=USERNAME
connection-password=PASSWORD
The DB2 JDBC driver documentation contains information about format and parameters of the JDBC URL.
To install the DB2 Database connector, use the following steps:
Add the DB2 JDBC driver JAR files to the
plugin/db2
directory.Add a catalog properties file (e.g.
db2.properties
for a catalog nameddb2
).Perform the above steps on every node.
Restart SEP on every node.
Type mapping#
Because SEP and DB2 each support types that the other does not, this connector modifies some types when reading or writing data.
Type mapping for reading data#
The connector supports reading the following DB2 types and performs conversion to PrestoSQL types with the detailed mappings.
DB2 type |
Trino type |
Notes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Type mapping for writing data#
The connector supports writing the following Trino types and performs conversion to DB2 types with the detailed mappings.
Trino type |
DB2 type |
Notes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For |
|
|
For |
|
|
When no bound is given. |
|
|
For |
|
|
|
|
|
|
|
|
|
|
|
Mapping datetime types#
The DB2 connector does not currently support variable-precision timestamps.
Selecting a DB2 timestamp value with fractional second precision greater than 3 truncates (not rounds) the fractional seconds to three digits.
Inserting a TIME
value with fractional seconds into DB2 truncates (not
rounds) the time to second precision, as DB2 does not support fractional seconds
in TIME
values.
Warning
Because of differences in date and time representation in DB2 and JDBC,
attempting to insert or select a datetime value earlier than 1582-10-15
results in an incorrect date being stored/retrieved.
General configuration properties#
The following properties can be used to configure how data types from the connected data source are mapped to Trino data types and how the metadata is cached in Trino.
Property name |
Description |
Default value |
---|---|---|
|
Configure how unsupported column data types are handled:
The respective catalog session property is |
|
|
Allow forced mapping of comma separated lists of data types to convert to
unbounded |
|
|
Support case insensitive database and collection names |
False |
|
1 minute |
|
|
Duration for which metadata, including table and column statistics, is cached |
0 (disabled caching) |
|
Cache the fact that metadata, including table and column statistics, is not available |
False |
SQL support#
The connector provides read and write access to data and metadata in the DB2 database. In addition to the globally available and read operation statements, the connector supports the following features:
SQL DELETE#
If a WHERE
clause is specified, the DELETE
operation only works if the
predicate in the clause can be fully pushed down to the data source.
Performance#
The connector includes a number of performance improvements, detailed in the following sections.
Table statistics#
The DB2 connector supports table and column statistics to improve query processing performance based on the actual data in the data source.
The statistics are collected by DB2 and retrieved by the connector.
To collect statistics for a table, execute the following statements in DB2.
CALL SYSPROC.ADMIN_CMD('RUNSTATS ON TABLE table_name');
Pushdown#
The connector supports pushdown for a number of operations:
Aggregate pushdown for the following functions:
variance()
andvar_samp()
Dynamic filtering#
Dynamic filtering is enabled by default. It causes the connector to wait for dynamic filtering to complete before starting a JDBC query.
You can disable dynamic filtering by setting the property
dynamic-filtering.enabled
in your catalog properties file to false
.
JDBC connection pooling#
You can improve performance by enabling JDBC connection pooling, which is disabled by default.
Starburst Cached Views#
The connectors supports table scan redirection to improve performance and reduce load on the data source.
Security#
The connector includes a number of security-related features, detailed in the following sections.
User impersonation#
DB2 connector supports user impersonation.
User impersonation can be enabled in your catalog file:
db2.impersonation.enabled=true
User impersonation is based on SET SESSION_USER
detailed in the IBM
documentation.
Note
Running SET SESSION_USER
in DB2 requires the user to have a
SETSESSIONUSER
privilege.
Password credential pass-through#
The connector supports password credential pass-through. To enable it, edit the catalog properties file to include the authentication type:
db2.authentication.type=PASSWORD_PASS_THROUGH
For more information about configurations and limitations, see Password credential pass-through.