Skip to content

Conversation

@zeroshade
Copy link
Member

@zeroshade zeroshade commented Oct 22, 2025

A draft for a possible update to the ADBC API to add several driver methods:

  • AdbcStatementExecuteQueryAsync
  • AdbcStatementNextResultSet
  • AdbcStatementNextResultSetAsync
  • AdbcConnectionReadPartitionAsync

This would also be a 1.2.0 revision of the ADBC API

Actually implementing these functions would be done in a separate PR once we've reached consensus on this addition to the API

/// being returned successfully. ADBC_STATUS_NOT_FOUND is returned
/// when there are no more result sets.
ADBC_EXPORT
AdbcStatusCode AdbcStatementNextResultSet(struct AdbcStatement* statement,
Copy link
Contributor

@CurtHagenlocher CurtHagenlocher Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if this also worked for "schema-only" evaluation. (I started down this road last year and my work-in-progress was at main...CurtHagenlocher:arrow-adbc:MoreResults.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have AdbcStatementExecuteSchema for schema-only evaluation, so you're suggesting a NextResultSet function for that one too?

@lidavidm
Copy link
Member

Do we want async variants of things like GetObjects, Prepare, etc.?

@CurtHagenlocher
Copy link
Contributor

From a tactical perspective, should 1.2-related work all happen on a separate branch (at least until we feel the proposed changes have been proven out)?

On an unrelated note, are there Arrow interop tests yet for the device APIs? I seem to recall that there weren't any a year ago.

@lidavidm
Copy link
Member

From a tactical perspective, should 1.2-related work all happen on a separate branch (at least until we feel the proposed changes have been proven out)?

Yeah, I think that'll have to be what happens due to the header changes.

///
/// A partition can be retrieved from AdbcPartitions.
///
/// This AdbcConnection must outlive the ArrowAsyncDeviceStreamHandler.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to comment on the lifetime of serialized_partition too - does it need to live until the call returns or until the callback finishes?

ADBC_EXPORT
AdbcStatusCode AdbcStatementExecuteQueryAsync(
struct AdbcStatement* statement, struct ArrowAsyncDeviceStreamHandler* handler,
int64_t* rows_affected, struct AdbcError* error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would rows_affected be populated? Maybe it should be included in schema metadata or something instead...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could go in ArrowAsyncProducer's additional_metadata. Or, provide an AdbcAsyncProducerGetMetadata(ArrowAsyncProducer*) like how we have an AdbcErrorFromArrayStream. (Speaking of which, we need an equivalent of that for the async stream.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's a good point. Since it's an asynchronous execution it wouldn't be populated before returning. I guess we can define a canonical metadata key to indicate total rows?

@lidavidm
Copy link
Member

Not to expand the scope too much, but looking at #1514 I wonder if we should add this parameter to Execute. (It might be cleaner to just add a separate call for it, though.)

@zeroshade
Copy link
Member Author

Do we want async variants of things like GetObjects, Prepare, etc.?

I'm not sure if an async variant of Prepare makes that much sense, but it would make sense to add async variants for anything that currently returns an ArrowArrayStream such as GetObjects etc.

Would an async variant for Prepare be something like AdbcStatementPrepare(struct AdbcStatement*, void (*on_prepared)(struct AdbcStatement*, struct AdbcError*)) where it returns immediately and calls on_prepared when it finishes (with the error being non-nil if there was an error, and being nil if successful)?

@zeroshade
Copy link
Member Author

Added more functions based on the comments and back-and-forth here. The current collection of new functions is:

  • ConnectionGetInfoAsync
  • ConnectionGetObjectsAsync
  • ConnectionGetTableSchemaAsync
  • ConnectionGetTableTypesAsync
  • ConnectionGetStatisticsAsync
  • ConnectionGetStatisticNamesAsync
  • ConnectionReadPartitionAsync
  • StatementExecuteSchemaAsync
  • StatementNextResultSetSchema
  • StatementNextResultSetSchemaAsync
  • StatementExecutePartitionsAsync
  • StatementNextResultSet
  • StatementExecuteQueryAsync
  • StatementNextResultSetAsync

Not to expand the scope too much, but looking at #1514 I wonder if we should add this parameter to Execute. (It might be cleaner to just add a separate call for it, though.)

personally, I'd prefer a separate call for this and do it in a follow-up PR rather than in this one. But I'm open to it here if there's consensus.

@lidavidm
Copy link
Member

Prepare may have to do I/O, hence it should have an async variant.

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Probably an async wrapper around a sync array stream in nanoarrow would help fill some of these in.

It's a bummer we have to repeat so much documentation but I suppose the existing documentation has mostly stayed the same.

Not to expand the scope too much, but looking at #1514 I wonder if we should add this parameter to Execute. (It might be cleaner to just add a separate call for it, though.)

I would love this (although I think a separate function makes sense). I can write that up as separate PR if that would be helpful.

@zeroshade
Copy link
Member Author

zeroshade commented Oct 24, 2025

Awesome! Probably an async wrapper around a sync array stream in nanoarrow would help fill some of these in.

Wouldn't it make more sense to just have nanoarrow implement the Async stream handler from the C Data interface?

I can write that up as separate PR if that would be helpful.

It would! Thanks!

@zeroshade
Copy link
Member Author

Prepare may have to do I/O, hence it should have an async variant.

Added StatementPrepareAsync

@paleolimbot
Copy link
Member

I can write that up as separate PR if that would be helpful.

It would! Thanks!

#3623

@lidavidm
Copy link
Member

Just a shower thought (that can be split into a separate discussion) but I wonder, instead of adding async and non-async versions of APIs that don't return data, we could just add a set of AdbcStatementWait, AdbcConnectionWait, AdbcDatabaseWait that set the callback for whatever operations were just performed (probably this is too complex vs just adding duplicate functions though)

@zeroshade
Copy link
Member Author

instead of adding async and non-async versions of APIs that don't return data, we could just add a set of AdbcStatementWait, AdbcConnectionWait, AdbcDatabaseWait that set the callback for whatever operations were just performed (probably this is too complex vs just adding duplicate functions though)

I like the idea that lets us avoid needing to have async and non-async versions of the functions, but I think this might be too complex. @CurtHagenlocher @paleolimbot thoughts?

Comment on lines +2476 to +2477
/// being returned successfully. ADBC_STATUS_NOT_FOUND is returned
/// when there are no more result sets.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like overloading the return code. I think it'd be more consistent to return a schema with no release callback.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update this to do that, then I'll attempt to implement these APIs and see how it goes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants