Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Add development guide #63

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Development

Developers should follow the [development guidelines](https://github.com/trinodb/trino/blob/81e9233eae31f2f3b425aa63a9daee8a00bc8344/DEVELOPMENT.md)
from the Trino community.

## Build

mvn clean install

## Build a container image including this connector

It uses multi-stage build and the prestosql container image from community as the
base image.

docker build -t "<name>/<tag>" --build-arg BASE="prestosql/presto:347" .

## Testing

So far, it still depends on manual integration testing against an actual Db2
database after coding a feature in Java code.

I'd recommend following this process to iterate:

1. Clone this repo to a local development environment, e.g., IntelliJ IDEA. And
keep code changes in a branch.
1. Run `mvn clean install` or the Maven tool window of the IDE to build this
connector, while addressing errors/problems from build output.
1. Config a separate prestosql server with the built connector by creating a file
named `docker-compose.yml`:
```YAML
# docker-compose.yml
version: "3.7"

services:
presto-coordinator:
image: prestosql/presto:347
container_name: presto-coordinator
volumes:
- source: ./target/presto-db2-347
target: /usr/lib/presto/plugin/db2
type: bind
- source: ./conf/presto
target: /etc/presto
type: bind
ports:
- "8080:8080"
```
1. Make sure creating a connector config under `./conf/presto/catalog` to connect
to an actual Db2 database. see details from [Connection Configuration](README.md#connection-configuration).
1. Start this local prestosql server by running `docker-compose up -d`
1. Connect to this local prestosql server via CLI to perform queries while
capturing server output from container logs by running command `docker logs presto-coordinator`.
1. If changing Java code, delete this local prestosql server by running command
`docker-compose down` then start from step 2.
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This is a plugin for [Presto](https://prestosql.io/) that allow you to connect t

Notice that it requires the connected database to be Db2 10 or Db2 LUW 9.7+ or greater versions to meet the precision need of the timestamp data type.

See [DEVELOPMENT](DEVELOPMENT.md) for information on development process.

## Connection Configuration

Create new properties file like `<catalog-name>.properties` inside `etc/catalog` dir:
Expand All @@ -25,11 +27,10 @@ See the official document of DB2 JDBC details from the article [Connecting progr

## Configuration Properties


| Property Name | Description |
|---------------|-------------|
|db2.varchar-max-length | max length of VARCHAR type in a CREATE TABLE or ALTER TABLE command. default is `32672`|
|db2.iam-api-key | API Key of IBM Cloud IAM. Use this when choosing IAM authentication instead of user/password |
|`db2.varchar-max-length` | max length of VARCHAR type in a CREATE TABLE or ALTER TABLE command. default is `32672`|
|`db2.iam-api-key` | API Key of IBM Cloud IAM. Use this when choosing IAM authentication instead of user/password |

**Notice**: you may need to customize value of `db2.varchar-max-length` to `32592` when using Db2 warehouse.

Expand All @@ -47,15 +48,4 @@ password-credential-name=db2_password
presto --extra-credential db2_user=user1 --extra-credential db2_password=secret
```

See details from [this answer](https://stackoverflow.com/a/58634432/914967).

## Building Presto DB2 JDBC Plugin

mvn clean install

## Build a presto container image including this connector

It use multi-stage build and the prestosql container image from community as the
base image.

docker build -t "<name>/<tag>" --build-arg BASE="prestosql/presto:347" .
See details from [this answer](https://stackoverflow.com/a/58634432/914967).