Skip to content

Conversation

@xborder
Copy link
Contributor

@xborder xborder commented Dec 10, 2025

What's Changed

This PR adds UUID support to the Arrow Flight SQL JDBC driver, enabling JDBC applications to work with UUID data types when connecting to Flight SQL servers that use Arrow's canonical arrow.uuid extension type.

Key Implementation Details

  • Added ArrowFlightJdbcUuidVectorAccessor to handle reading UUID values from UuidVector
    • getObject() returns java.util.UUID directly
    • getString() returns the standard hyphenated UUID format (e.g., "550e8400-e29b-41d4-a716-446655440000")
    • getBytes() returns the 16-byte binary representation
  • Added UuidAvaticaParameterConverter to handle parameter binding for UUID columns
    • Supports binding java.util.UUID objects directly via setObject()
    • Supports binding UUID string representations via setString()
    • Supports binding 16-byte arrays via setBytes()
  • UUID extension type maps to java.sql.Types.OTHER.
  • Updated SqlTypes to recognize UuidType and return appropriate SQL type ID

Examples

            try (Statement stmt = conn.createStatement();
                 ResultSet rs = stmt.executeQuery("SELECT id, session_id FROM sessions")) {
                while (rs.next()) {
                    int id = rs.getInt("id");
                    // getObject() returns java.util.UUID directly
                    UUID sessionId = rs.getObject("session_id", UUID.class);
                    // getString() returns hyphenated format: "550e8400-e29b-41d4-a716-..."
                    String sessionIdStr = rs.getString("session_id");
                    
                    System.out.printf("ID: %d, UUID: %s%n", id, sessionId);
                }
            }
            
            // Use PreparedStatement to bind UUID parameters
            String sql = "SELECT * FROM sessions WHERE session_id = ?";
            try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
                UUID targetId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
                // Bind UUID directly with setObject()
                pstmt.setObject(1, targetId);
                // Or bind as string: pstmt.setString(1, targetId.toString());
                
                try (ResultSet rs = pstmt.executeQuery()) {
                    if (rs.next()) {
                        System.out.println("Found: " + rs.getObject("session_id"));
                    }
                }
            }

Closes #929.

@github-actions

This comment has been minimized.

@lidavidm lidavidm added the enhancement PRs that add or improve features. label Dec 10, 2025
@github-actions github-actions bot added this to the 18.4.0 milestone Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement PRs that add or improve features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add UUID support for JDBC Driver

2 participants