[
https://issues.apache.org/jira/browse/ARROW-16035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17531982#comment-17531982
]
Jonathan Swenson commented on ARROW-16035:
------------------------------------------
Just a heads up, the isLast method is not necessarily supported by all JDBC
ResultSet implementations and is called out as optional in the JDBC
documentation.
{quote}Note: Support for the isLast method is optional for ResultSets with a
result set type of TYPE_FORWARD_ONLY
{quote}
Additionally it can be somewhat expensive as it may require fetching ahead
{quote}Note: Calling the method isLast may be expensive because the JDBC driver
might need to fetch ahead one row in order to determine whether the current row
is the last row in the result set.
{quote}
[https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/ResultSet.html#isLast()]
The previous implementation, using isAfterLast() supposedly is expected to be
implemented by all JDBC drivers, or at least is not called out as optional.
cc [~toddfarmer] I'm not sure if this will further reduce the number of JDBC
drivers that are supported.
> [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: 40m
> 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)