PostgreSQL JDBC Catalog
Run catalog SQL with a warehouse SQL user that can manage catalogs and access the source. Ensure network access from the warehouse to metadata, storage, and source endpoints. For connector deployment, host files, JVM settings, or service configuration changes, contact VeloDB Cloud support.
JDBC Catalog supports connecting to PostgreSQL databases via the standard JDBC interface. This document describes how to configure a PostgreSQL database connection.
For an overview of JDBC Catalog, please refer to: JDBC Catalog Overview
Usage notes
To connect to a PostgreSQL database, you need
-
PostgreSQL 11.x or higher
-
JDBC driver for PostgreSQL database, which you can download the latest or specified version from Maven Repository. It is recommended to use PostgreSQL JDBC Driver version 42.5.x or above.
-
Network access from the warehouse to the source server, whose default port is 5432.
Connect to PostgreSQL
CREATE CATALOG postgresql_catalog PROPERTIES (
'type' = 'jdbc',
'user' = 'username',
'password' = 'pwd',
'jdbc_url' = 'jdbc:postgresql://host:5432/postgres',
'driver_url' = 'postgresql-42.5.6.jar',
'driver_class' = 'org.postgresql.Driver'
);
jdbc_url defines the connection information and parameters to be passed to the PostgreSQL JDBC driver. Supported URL parameters can be found in the PostgreSQL JDBC Driver Documentation.
Connection security
If you have configured TLS with a globally trusted certificate installed on the data source, you can enable TLS between the cluster and the data source by appending parameters to the JDBC connection string set in the jdbc_url property.
For example, for version 42 of the PostgreSQL JDBC driver, enable TLS by adding the ssl=true parameter to the jdbc_url configuration property:
"jdbc_url"="jdbc:postgresql://example.net:5432/database?ssl=true"
For more information on TLS configuration options, please refer to the PostgreSQL JDBC Driver Documentation.
Hierarchical mapping
When mapping PostgreSQL, a Database in VeloDB Cloud corresponds to a Schema under a specified database in PostgreSQL (as in the example jdbc_url parameter under postgres). A Table under a Database in VeloDB Cloud corresponds to Tables under that Schema in PostgreSQL. The mapping relationship is as follows:
| VeloDB Cloud | PostgreSQL |
|---|---|
| Catalog | Database |
| Database | Schema |
| Table | Table |
Column type mapping
| PostgreSQL Type | VeloDB Cloud Type | |
|---|---|---|
| boolean | boolean | |
| smallint/int2 | smallint | |
| integer/int4 | int | |
| bigint/int8 | bigint | |
| decimal/numeric | decimal(P, S) / string | Numeric without precision will be mapped to string type, and needs to be converted to decimal type for numerical calculations, and does not support write-back. |
| real/float4 | float | |
| double | double | |
| smallserial | smallint | |
| serial | int | |
| bigserial | bigint | |
| char(N) | char(N) | |
| varchar/text | string | |
| timestamp(S) | datetime(S) | |
| timestamptz(S) | DATETIME(S) / TIMESTAMPTZ(S) | DATETIME(S) by default; TIMESTAMPTZ(S) when enable.mapping.timestamp_tz = true. Precision is capped at 6. A future release makes the instant-preserving mapping unconditional. |
| date | date | |
| json/jsonb | string | For better reading and computing performance balance, VeloDB Cloud maps JSON type to STRING type. |
| time | string | PostgreSQL time maps to STRING through this JDBC connector. |
| interval | string | |
| point/line/lseg/box/path/polygon/circle | string | |
| cidr/inet/macaddr | string | |
| uuid | string | |
| bit | boolean / string | VeloDB Cloud does not support bit type, bit type will be mapped to boolean when bit(1), otherwise mapped to string. |
| bytea | STRING / VARBINARY | STRING by default; VARBINARY when enable.mapping.varbinary = true. A future release makes the binary mapping unconditional. |
| array | array | Please refer to the following explanation regarding the mapping methods for array types. |
| other | UNSUPPORTED |
-
Array Types
In PostgreSQL, array types can be defined as follows:
col1 text[]col2 in4[][]However, the array dimensions cannot be directly obtained from the PostgreSQL metadata. For example,
text[]could be a one-dimensional array or a two-dimensional array. The array dimensions can only be determined after data is written.VeloDB Cloud requires the array dimensions to be explicitly declared. Therefore, VeloDB Cloud can only map correctly if the corresponding array column in PostgreSQL contains data; otherwise, the array column will be mapped as
UNSUPPORTED.
Appendix
Time zone issues
By default, enable.mapping.timestamp_tz is false, so PostgreSQL timestamptz maps to DATETIME and the JDBC read path converts values to local time. The managed JVM time zone can therefore affect the value read through this mapping. Confirm the JVM time zone with VeloDB Cloud support and set the SQL session time_zone consistently.
When enable.mapping.timestamp_tz = true, timestamptz maps to TIMESTAMPTZ, preserving the instant and displaying it in the session time zone. Both mappings support at most six fractional digits.