Skip to content

branch-4.2: [fix](jdbc) Fix PostgreSQL array dimensions without values - #71026

Merged
yiguolei merged 1 commit into
apache:branch-4.2from
suxiaogang223:codex/pick-pg-array-dimensions-4.2
Nov 26, 2026
Merged

yiguolei merged 1 commit into
apache:branch-4.2from
suxiaogang223:codex/pick-pg-array-dimensions-4.2

Conversation

@suxiaogang223

Copy link
Copy Markdown
Member

Background

The release-branch PostgreSQL JDBC client infers array dimensions by sampling a non-NULL table value. The connector implementation on master already uses declared dimensions from PostgreSQL system catalogs, while this branch still uses array_ndims on row data.

What problem does this PR solve?

Issue Number: None
Related PR: #62183 (contains the metadata lookup in the connector implementation)
PR Type: Bugfix

Problem Summary:

Backport the PostgreSQL array-dimension metadata lookup to the release branch's existing JDBC client. Read pg_attribute.attndims through a prepared query so all-NULL and empty-array columns can be mapped without requiring a non-empty row. Keep the branch's existing metadata filters and type mappings and add the original one-/two-dimensional NULL and empty-array regression fixtures and results.

Details

  • Frequency: When an array column has only NULL or empty-array values at metadata loading time.
  • Root cause: array_ndims sampling yields no usable dimensions for these values, leaving the array type unsupported.
  • Why existing tests missed it: Existing array cases contained non-empty values; they did not cover entirely NULL or empty one-/two-dimensional columns.
  • Fix: Query attndims by schema, table and column using bound parameters and pass the result through the existing JdbcFieldSchema and nested-array conversion path.
  • Other paths and branches: Scalar metadata and all existing branch-specific filters/type mappings are preserved. The same isolated fix is being backported to maintained 4.0, 4.1 and 4.2 release branches.
  • Behavior change: Array metadata uses the declared dimensions even when table values contain no dimension information.

Testing

  • Passed ./build.sh --fe -j4 on this target branch with macOS ARM64, JDK 17 and Maven 3.9.8. FE source/test-source compilation, Checkstyle for modified Java sources and output packaging succeeded; optional UI, JuiceFS, Hive UDF and BE Java-extension builds were disabled locally.
  • Static checks verified that exactly five intended files changed, that the production edit applies the original metadata lookup while retaining all other branch-specific code, and that the original regression output sections are preserved byte for byte. No golden output was handwritten or regenerated.
  • Source whitespace checks passed. Original TSV output trailing columns are retained.
  • PostgreSQL external-docker regression was not run because the local Docker daemon is unavailable. No unit or live regression test execution is claimed.
  • Local-only build environment adjustment: gated the unrelated native third-party rebuild check on BUILD_BE/BUILD_CLOUD so --fe did not rebuild BE dependencies. Used a local Thrift 0.24 generator matching the branch runtime and regenerated stale local sources. The tracked build.sh was restored before committing; no build-script or generated-code change is included.

Release note

Fix PostgreSQL JDBC type mapping for array columns containing only NULL or empty arrays, including declared two-dimensional arrays.

Check List (For Author)

  • Behavior changed: Yes (see Details).
  • Does this need documentation: No.
  • Pre-submission status: Partially verified: FE build and static checks passed; PostgreSQL external-docker regression was not run because the local Docker daemon is unavailable.

AI Disclosure

  • Tool: Codex (GPT-6).
  • Generated: Backport adaptation, validation and this description.
  • Human review: Pending.

### Background

The release-branch PostgreSQL JDBC client infers array dimensions by sampling a non-NULL table value. The connector implementation on master already uses declared dimensions from PostgreSQL system catalogs, while this branch still uses array_ndims on row data.

### What problem does this PR solve?

Issue Number: None
Related PR: apache#62183 (contains the metadata lookup in the connector implementation)
PR Type: Bugfix

Problem Summary:

Backport the PostgreSQL array-dimension metadata lookup to the release branch's existing JDBC client. Read pg_attribute.attndims through a prepared query so all-NULL and empty-array columns can be mapped without requiring a non-empty row. Keep the branch's existing metadata filters and type mappings and add the original one-/two-dimensional NULL and empty-array regression fixtures and results.

### Details

- **Frequency:** When an array column has only NULL or empty-array values at metadata loading time.
- **Root cause:** array_ndims sampling yields no usable dimensions for these values, leaving the array type unsupported.
- **Why existing tests missed it:** Existing array cases contained non-empty values; they did not cover entirely NULL or empty one-/two-dimensional columns.
- **Fix:** Query attndims by schema, table and column using bound parameters and pass the result through the existing JdbcFieldSchema and nested-array conversion path.
- **Other paths and branches:** Scalar metadata and all existing branch-specific filters/type mappings are preserved. The same isolated fix is being backported to maintained 4.0, 4.1 and 4.2 release branches.
- **Behavior change:** Array metadata uses the declared dimensions even when table values contain no dimension information.

### Testing

- Passed ./build.sh --fe -j4 on this target branch with macOS ARM64, JDK 17 and Maven 3.9.8. FE source/test-source compilation, Checkstyle for modified Java sources and output packaging succeeded; optional UI, JuiceFS, Hive UDF and BE Java-extension builds were disabled locally.
- Static checks verified that exactly five intended files changed, that the production edit applies the original metadata lookup while retaining all other branch-specific code, and that the original regression output sections are preserved byte for byte. No golden output was handwritten or regenerated.
- Source whitespace checks passed. Original TSV output trailing columns are retained.
- PostgreSQL external-docker regression was not run because the local Docker daemon is unavailable. No unit or live regression test execution is claimed.
- Local-only build environment adjustment: gated the unrelated native third-party rebuild check on BUILD_BE/BUILD_CLOUD so --fe did not rebuild BE dependencies. Used a local Thrift 0.24 generator matching the branch runtime and regenerated stale local sources. The tracked build.sh was restored before committing; no build-script or generated-code change is included.

### Release note

Fix PostgreSQL JDBC type mapping for array columns containing only NULL or empty arrays, including declared two-dimensional arrays.

### Check List (For Author)

- Behavior changed: Yes (see Details).
- Does this need documentation: No.
- Pre-submission status: Partially verified: FE build and static checks passed; PostgreSQL external-docker regression was not run because the local Docker daemon is unavailable.

### AI Disclosure

- Tool: Codex (GPT-6).
- Generated: Backport adaptation, validation and this description.
- Human review: Pending.

(cherry picked from commit b0bdfc5cac580f0637e9d6b22dc169b633e89161)
@shuke987

Copy link
Copy Markdown
Contributor

run compile

@suxiaogang223 suxiaogang223 changed the title [fix](jdbc) Fix PostgreSQL array dimensions without values (branch-4.2) branch-4.2: [fix](jdbc) Fix PostgreSQL array dimensions without values Nov 26, 2026
@yiguolei
yiguolei merged commit 30772b8 into apache:branch-4.2 Nov 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants