Skip to content

GH-1100: Report struct columns as JDBC STRUCT in Flight SQL - #1546

Open
yucheng-du wants to merge 2 commits into
apache:mainfrom
yucheng-du:struct-column-metadata
Open

yucheng-du wants to merge 2 commits into
apache:mainfrom
yucheng-du:struct-column-metadata

Conversation

@yucheng-du

Copy link
Copy Markdown

What's Changed

Flight SQL JDBC now reports Arrow struct columns as Types.STRUCT with type name STRUCT. Untyped getObject() still returns a map keyed by field name. Callers can also request java.sql.Struct to read attributes in schema order.

The regression test checks metadata before the first row, both object representations, and a null struct. On JDK 21 the JDBC core and its dependencies passed 4,697 tests with 74 skipped. I also checked nested structs and arrays of structs over a local Flight SQL connection.

AI assistance: GPT-6.2 Astra, ultra effort.

Closes #1100.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Thank you for opening a pull request!

Please label the PR with one or more of:

  • bug-fix
  • chore
  • dependencies
  • documentation
  • enhancement

Also, add the 'breaking-change' label if appropriate.

See CONTRIBUTING.md for details.

@Ap-95671 Ap-95671 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.

I checked the new typed JDBC Struct path on JDK 21. The existing attribute assertion passed, and the extra assertion using an empty type map reproduced the exception noted inline.

AI-assisted review with OpenAI Codex, submitted on behalf of Ap-95671.

@Override
public <T> T getObject(Class<T> type) throws SQLException {
if (type == Struct.class) {
return type.cast(getStruct());

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.

[P2] Support an empty JDBC type map on the new Struct return value. I extended testStructMetadataAndObjectAccess with assertArrayEquals(new Object[] {12}, result.getObject(1, Struct.class).getAttributes(Map.of())). On JDK 21 this throws UnsupportedOperationException from Avatica’s StructImpl; the no-arg call directly above it returns [12]. An empty map should use the default attribute mappings. Could the returned Struct delegate that case to getAttributes() and report unsupported custom mappings as a SQLException subtype?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in aecdef0. Empty and null type maps now return the same attributes as getAttributes(). A nonempty map throws SQLFeatureNotSupportedException. The regression test covers all three cases. I also checked nested structs and null rows over a local Flight SQL connection on JDK 21. The JDBC core Maven build and its dependencies passed (4,697 tests passed, 74 skipped).

@lidavidm lidavidm added the bug-fix PRs that fix a big. label Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose Arrow Struct columns as JDBC STRUCT metadata in the Flight SQL JDBC driver.

3 participants