xborder opened a new pull request, #930:
URL: https://github.com/apache/arrow-java/pull/930

   ## 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**
   ``` java
               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.
   


-- 
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]

Reply via email to