-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: avoid allocating ADBC inputs and outputs twice #97
Conversation
At the moment we have something like Current version (up til 614e4a4){:ok,
results = %Adbc.Result{
data: %Adbc.Column{
data: [#Reference<0.351247108.3006922760.20174>],
name: "",
type:
{:struct,
[
%Adbc.Column{
name: "num",
type: :s64,
metadata: nil,
nullable: true
}
]},
metadata: nil,
nullable: true
},
num_rows: nil
}} = Connection.query(conn, "SELECT 123 as num") Maybe it would be easier to use if the reference data is associated with the actual column: Result with a single column (todo){:ok,
results = %Adbc.Result{
data: %Adbc.Column{
data: [
%Adbc.Column{
name: "num",
type: :s64,
metadata: nil,
nullable: true,
data: #Reference<0.351247108.3006922760.20174>
}
],
name: "",
type: :struct,
metadata: nil,
nullable: true
},
num_rows: nil
}} = Connection.query(conn, "SELECT 123 as num") Result with multiple columns (todo){:ok,
results = %Adbc.Result{
data: %Adbc.Column{
data: [
%Adbc.Column{
name: "num",
type: :s64,
metadata: nil,
nullable: true,
data: #Reference<0.351247108.3006922760.20174>
},
%Adbc.Column{
name: "fp",
type: :f64,
metadata: nil,
nullable: true,
data: #Reference<0.351247108.3006922760.20175>
}
],
name: "",
type: :struct,
metadata: nil,
nullable: true
},
num_rows: nil
}} = Connection.query(conn, "SELECT 123 as num, 456.78 as fp") This probably looks better. WDYT? @josevalim |
@cocoa-xu what does ADBC return? Several columns or a struct with multiple entries? |
It's the latter. The results will always be a struct at the top-level, and it contains all the columns. |
Co-authored-by: José Valim <[email protected]>
Hrmmm, msvc doesn't like some code in arrow-adbc when compiling in debug mode
|
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.
This is great! One comment to migrate to a list of refs and we can ship it!!
Co-authored-by: José Valim <[email protected]>
CI all green and looks great, I'll go ahead and merge it! |
This PR should allow us to use query results as inputs (query parameters) without allocating twice.
However, by the design of ADBC, the value ofArrowArray
andArrowSchema
will be moved once used as a parameter. And there is no deep copy function forArrowArray
comes with the nanoarrow library.It's possible to write one that does a deep copy of theArrowArray
but I'm not sure if that's what we wanted to do. But if so, I'll be happy to write one and send another PR for it.Actually, a shallow copy + setting
release
to nullptr seems to be fine, and we can now reuse the results multiple times.