PostgreSQL database plugin

Introduction

A separate database plugin to support PostgreSQL-specific features and configurations.

Use-Case

  • Users can choose and install PostgreSQL source and sink plugins.
  • Users should see PostgreSQL logo on plugin configuration page for better experience.
  • Users should get relevant information from the tool tip:
    • The tool tip for the connection string should be customized specifically to the PostgreSQL database,
    • The tool tip should describe accurately what each field is used for.
  • User should get a performance comparable to Sqoop by utilizing sqoop libraries for the data ingestion and egress.
  • Users should not have to specify any redundant configuration (ex: JDBC type in source plugin, columns in the sink plugin).
  • Users should get field level lineage for the source and sink that is being used.
  • Reference documentation should be updated to account for the changes.
  • The source code for PostgreSQL database plugin should be placed in repo under data-integrations org.
  • Integration tests for PostgreSQL database plugin should be added in the test repo.
  • The data pipeline using source and sink plugins should run on both mapreduce and spark engines.

User Stories

  • User should be able to install PostgreSQL specific database source and sink plugins from the Hub
  • Users should have each tool tip accurately describe what each field does
  • Users should get field level lineage information for the PostgreSQL source and sink 
  • Users should get a performance comparable to Sqoop when ingesting data from PostgreSQL and while writing data to PostgreSQL (within ~15% of the time taken for sqoop)
  • Users should be able to setup a pipeline avoiding specifying redundant information
  • Users should get updated reference document for PostgreSQL source and sink
  • Users should be able to read all the DB types

Plugin Type

  • Batch Source
  • Batch Sink 
  • Real-time Source
  • Real-time Sink
  • Action
  • Post-Run Action
  • Aggregate
  • Join
  • Spark Model
  • Spark Compute

Design Tips

PostgreSQL connector reference: https://jdbc.postgresql.org/download/postgresql-9.4.1211.jar

Existing database plugins: https://github.com/cdapio/hydrator-plugins/tree/develop/database-plugins

PostgreSQL datatypes mappings and conversions:


Design

The suggestion is to create maven submodule PostgreSQL under database-plugins repo.


Sink Properties

User Facing NameTypeDescriptionConstraints
LabelString Label for UI
Reference NameStringUniquely identified name for lineage
HostStringPostgreSQL hostRequired (defaults to localhost on UI)
PortNumberSpecific port where PostgreSQL running on

Optional

(default 5432)

DatabaseStringDatabase name to connectRequired
UsernameStringDB usernameRequired
PasswordPasswordUser passwordRequired
Transaction Isolation LevelSelectTransaction isolation level for queries run by this sink
Connection ArgumentsKeyvalue

A list of arbitrary string tag/value pairs as connection arguments, list of properties

https://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters


Table NameStringName of a database table to write to
Connect TimeoutNumberThe timeout value used for socket connect operations. If connecting to the server takes longer than this value, the connection is broken. The timeout is specified in seconds and a value of zero means that it is disabled

Source Properties


User Facing NameTypeDescriptionConstraints
LabelStringLabel for UI
Reference NameStringUniquely identified name for lineage
HostStringPostgreSQL hostRequired (defaults to localhost on UI)
PortNumberSpecific port where PostgreSQL running on

Optional

(default 5432)
DatabaseStringDatabase name to connectRequired
Import QueryStringQuery for import dataValid SQL query
UsernameStringDB usernameRequired
PasswordStringUser passwordRequired
Bounding QueryStringReturns max and min of split-By FiledValid SQL query
Split-By Field NameStringField name which will be used to generate splits
Number of Splits to GenerateNumberNumber of splits to generate
Transaction Isolation LevelSelectTransaction isolation level for queries run by this sink
Connection ArgumentsKeyvalueA list of arbitrary string tag/value pairs as connection arguments, list of properties https://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters
Connect TimeoutNumberThe timeout value used for socket connect operations. If connecting to the server takes longer than this value, the connection is broken. The timeout is specified in seconds and a value of zero means that it is disabled


Action Properties


User Facing NameTypeDescriptionConstraints
LabelStringLabel for UI
HostStringPostgreSQL hostRequired (defaults to localhost on UI)
PortNumberSpecific port where PostgreSQL running on

Optional

(default 5432)
DatabaseStringDatabase name to connectRequired
Username

String

DB usernameRequired
PasswordStringUser passwordRequired
Connection ArgumentsKeyvalue

A list of arbitrary string tag/value pairs as connection arguments, list of properties 

https://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters


Database CommandStringDatabase command to runValid SQL query
Connect TimeoutNumberThe timeout value used for socket connect operations. If connecting to the server takes longer than this value, the connection is broken. The timeout is specified in seconds and a value of zero means that it is disabled


Data Types Mapping

Postgres Data TypeCDAP Schema Data TypeSupportComment
BIGINTSchema.Type.LONG+
BIGSERIALSchema.Type.LONG+Serial is autoincremented
BIT(N)Schema.Type.STRING+Bit strings are strings of 1's and 0's
BIT VARYING(N)Schema.Type.STRING+Bit strings are strings of 1's and 0's
BOOLEANSchema.Type.BOOLEAN+
BYTEASchema.Type.BYTES+
CHARACTERSchema.Type.STRING+
CHARACTER VARYINGSchema.Type.STRING+
DOUBLE PRECISIONSchema.Type.DOUBLE+
INTEGERSchema.Type.INT+
NUMERIC(p, s)/DECIMAL(p, s)Schema.LogicalType.DECIMAL+
REALSchema.Type.FLOAT+
SMALLINTSchema.Type.INT+
SMALLSERIALSchema.Type.INT+Serial is autoincremented
SERIALSchema.Type.INT+Serial is autoincremented
TEXTSchema.Type.STRING+
DATESchema.LogicalType.DATE+
TIME [ (P) ] [ WITHOUT TIME ZONE ]Schema.LogicalType.TIME_MICROS+
TIME [ (P) ] WITH TIME ZONESchema.Type.STRING+
TIMESTAMP [ (P) ] [ WITHOUT TIME ZONE ]Schema.LogicalType.TIMESTAMP_MICROS+
TIMESTAMP [ (P) ] WITH TIME ZONESchema.LogicalType.TIMESTAMP_MICROS+Postgresql converts it to UTC(see "Time Stamps" section)
XMLSchema.Type.STRING+
TSQUERYSchema.Type.STRING+
TSVECTORSchema.Type.STRING+
TXID_SNAPSHOT
-Postgresql specific, see documentation
UUIDSchema.Type.STRING+
BOXSchema.Type.STRING+
CIDRSchema.Type.STRING+
CIRCLESchema.Type.STRING+
INETSchema.Type.STRING+
INTERVALSchema.Type.STRING+
JSONSchema.Type.STRING+
JSONBSchema.Type.STRING+
LINESchema.Type.STRING+
LSEGSchema.Type.STRING+
MACADDRSchema.Type.STRING+
MACADDR8Schema.Type.STRING+
MONEYSchema.Type.STRING+
PATHSchema.Type.STRING+
PG_LSN
-Postgresql specific, see documentation
POINTSchema.Type.STRING+
POLYGONSchema.Type.STRING+



Approach

Create a module postgresql-plugin in database-plugins project, reuse existing database-plugins code if possible. Add PostgreSQL-specific properties to configuration, add support for PostgreSQL-specific datatypes. Update UI widgets JSON definitions.

Pipeline Samples


API changes

Deprecated Programmatic APIs

database-plugins is moved to Data Integrations

UI Impact or Changes

Configurable database properties are presented as named text fields instead of arbitrary key value pairs. PostgreSQL source and sink are separate entries with PostgreSQL logo in source and sink lists.

Test Scenarios

TODO

Releases

Release X.Y.Z

Related Work

Database plugin enhancements

Future work

Oracle database plugin