-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement array-based JDBC ResultSet #8972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
public DuckDBArrayResultSet(DuckDBVector vector, int offset, int length) { | ||
this.vector = vector; | ||
this.offset = offset; | ||
this.length = length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you haven't used this offset anywhere, this means this will break on multiple arrays being returned by a single query. Easiest fix is to just use the methods on the original Array implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mause Thank you! I was originally hoping to wrap DuckDBArray
instead of DuckDBVector
, but I only found an untyped Object getArray()
on it. Reusing vector seemed less error-prone than type-checking in every getter. Are there better ways of using DuckDBArray
that I missed?
In the meantime, I updated DuckDBArrayResultSet
to use the offset. I could not find a test case to force a non-zero offset -- do you know offhand what query would work to test this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like
SELECT UNNEST([[1], [2]])
Should give a non zero offset, by having two list rows for a single column
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! That worked to expose the offset issue on the previous implementation of getValue()
. I added the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch to DuckDBArray
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@Mytherin Is there anything blocking this PR getting merged? It's not a super important part of JDBC spec, but we had a user bring up that it was throwing Unsupported. |
No this is ready to merge - thanks! |
JDBC spec allows getting an array/list type as a 2-column
ResultSet
with the first column containing indices and the second column containing values.This PR implements a
ResultSet
wrapper around an existing result vector.