[ 
https://issues.apache.org/jira/browse/ARROW-16035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17534049#comment-17534049
 ] 

Jonathan Swenson commented on ARROW-16035:
------------------------------------------

Thanks [~toddfarmer] I didn't realize that isAfterLast is also optional. I now 
see that using isAfterLast was discussed back when it was added as well. 
Avoiding using these optional features is likely desirable, but this doesn't 
add any _extra_ incompatibility.

I'm looking into using the JDBC -> arrow functionality with a variety of 
different JDBC drivers in the future, but I'm currently not aware of which JDBC 
drivers implement all of these optional features. 

I believe that the "empty" vector schema root makes sense as it can also return 
schema metadata about the (empty) result set which mirrors the JDBC ResultSet 
metadata associated with running a SQL query JDBC query. 

> [Java] Arrow to JDBC ArrowVectorIterator with does not terminate with empty 
> result set
> --------------------------------------------------------------------------------------
>
>                 Key: ARROW-16035
>                 URL: https://issues.apache.org/jira/browse/ARROW-16035
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: 7.0.0
>            Reporter: Jonathan Swenson
>            Assignee: Todd Farmer
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 8.0.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Using an ArrowVectorIterator built from a JDBC Result Set that is empty 
> causes the iterator to never terminate. 
> {code:java}
> ArrowVectorIterator iterator =
>     JdbcToArrow.sqlToArrowVectorIterator(conn.createStatement()
>         .executeQuery("select 1 from table1 where false"), config); {code}
>  
> It appears as though this is due to the implementation of the 
> [hasNext()|https://github.com/apache/arrow/blob/master/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/ArrowVectorIterator.java#L158]
>  method.
> The expectation is that the `isAfterLast()` method on a JDBC result set 
> return true when the result set is empty. However, according to the [JDBC 
> documentation|https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/ResultSet.html#isAfterLast()]
>  it will always return false when the result set is empty. 
> {quote}Returns:{{{}true{}}} if the cursor is after the last row; {{false}} if 
> the cursor is at any other position or the result set contains no rows
> {quote}
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to