laughingman7743 opened a new pull request, #256:
URL: https://github.com/apache/flink-connector-jdbc/pull/256
## What is the purpose of the change
The PostgreSQL dialect can read ARRAY columns, but writing them failed with
`Writing ARRAY type is not yet supported in JDBC:PostgreSQL.` This PR adds
ARRAY write support, building on
`FieldNamedPreparedStatement#setArray`/`#createArrayOf` that were added with
the Spanner dialect (FLINK-37288).
## Brief change log
- `PostgresDialectConverter` now handles ARRAY in
`createExternalConverter`. It creates the JDBC array with `createArrayOf` using
the PostgreSQL element type name (`int4`, `text`, `bytea`, ...) and sets it
with `setArray`. NULL arrays are handled by the parent's nullable converter.
- Elements are passed as a typed Java array (e.g. `byte[][]`), since
PgJDBC rejects `byte[]` elements inside an `Object[]`.
- Supported element types are the ones the read path supports.
TIMESTAMP_LTZ and nested arrays throw an `UnsupportedOperationException` naming
the element type.
## Verifying this change
This change added tests and can be verified as follows:
- `PostgresDynamicTableSinkITCase#testArray` writes arrays with NULL
elements, NULL arrays and empty arrays, and checks the stored values over JDBC.
- `PostgresCatalogITCase#testArrayTypesInsert` copies the existing
`array_table`, which covers all supported element types including `bytea`,
`char(n)`, `time` and NULL arrays, into `array_table2` through the catalog and
compares the rows.
- Both tests fail without the fix. The core, PostgreSQL and CrateDB
modules pass locally against Flink 2.1.3 and 2.3.0.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): yes, but only
the write path of ARRAY columns, which failed before
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? not applicable (the data type
mapping table already lists ARRAY for PostgreSQL)
---
##### Was generative AI tooling used to co-author this PR?
- [x] Yes (please specify the tool below)
Generated-by: Claude Code (Claude Opus 5.5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]