Skip to content

[FLINK-39224] Support JSON, JSONB types for PostgreSQL#189

Merged
RocMarshal merged 1 commit into
apache:mainfrom
och5351:feature/postgresql-catalog-jsonb-type-support
May 12, 2026
Merged

[FLINK-39224] Support JSON, JSONB types for PostgreSQL#189
RocMarshal merged 1 commit into
apache:mainfrom
och5351:feature/postgresql-catalog-jsonb-type-support

Conversation

@och5351

@och5351 och5351 commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

Currently, the Flink JDBC Connector for PostgreSQL does not support the json/jsonb data types. When users attempt to read a table containing json/jsonb columns through the PostgresCatalog, it fails with an UnsupportedOperationException: Doesn't support Postgres type 'jsonb' yet.

The json/jsonb types are widely used native data types in PostgreSQL for storing JSON documents.

Changes

This PR adds support for PostgreSQL json/jsonb types by mapping them to Flink's DataTypes.STRING().

baseUrl + "&stringtype=unspecified"

Since PostgreSQL's JDBC driver returns json/jsonb values as Java String, users can leverage Flink's JSON functions (e.g., JSON_QUERY, JSON_VALUE) to process these columns.

Test Cases

  1. Dynamic Table Source
    • Added a new test case for json type in PostgresDynamicTableSourceITCase.getTestData()
  2. Catalog
    • Added test cases for json/jsonb type mapping in the PostgreSQL catalog

@RocMarshal RocMarshal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @och5351 for the PR.
LGTM on the whole just left a few of comments.

String.format("'%s'", jsonNode.toString()));
}

public static TestTable getJsonbTable() throws JsonProcessingException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static TestTable getJsonbTable() throws JsonProcessingException {
static TestTable getJsonbTable() throws JsonProcessingException {

return json.replaceAll(":", ": ").replaceAll(",", ", ");
}

public static TestTable getJsonTable() throws JsonProcessingException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static TestTable getJsonTable() throws JsonProcessingException {
static TestTable getJsonTable() throws JsonProcessingException {

"1, NULL");
}

public static String transformPGJsonb(String json) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static String transformPGJsonb(String json) {
static String transformPGJsonb(String json) {

Could the method be removed into PostgresCatalogITCase?
Because it's used by PostgresCatalogITCase only.

@och5351 och5351 force-pushed the feature/postgresql-catalog-jsonb-type-support branch from bd010f0 to 88de511 Compare April 13, 2026 08:14
@och5351

och5351 commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @och5351 for the PR. LGTM on the whole just left a few of comments.

Hi, @RocMarshal !
Thank you for your review.

I agree :)
As you suggested, I have removed the public keyword from the transformPGJsonb, getJsonTable, and getJsonbTable methods in the PostgresCatalogTestBase.java file.

PTAL !!

@och5351 och5351 requested a review from RocMarshal April 13, 2026 08:20

@eskabetxe eskabetxe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @och5351

LGTM

@och5351

och5351 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for your contribution @och5351

LGTM

Thank you @eskabetxe !

Could you please run CI again?
It seems occuring an error in the core. However, it is working normally in my environment.  

image

@RocMarshal RocMarshal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @och5351 .
LGTM +1.

@RocMarshal RocMarshal merged commit 058eccb into apache:main May 12, 2026
8 of 25 checks passed
@RocMarshal RocMarshal changed the title [FLINK-39224] Support PostgreSQL JSON, JSONB type [FLINK-39224] Support JSON, JSONB types for PostgreSQL May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants