Skip to content
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

C-API: support streaming arrow query #8642

Merged
merged 1 commit into from
Nov 8, 2023
Merged

C-API: support streaming arrow query #8642

merged 1 commit into from
Nov 8, 2023

Conversation

Virgiel
Copy link

@Virgiel Virgiel commented Aug 21, 2023

Currently, the C-Arrow API uses a wrapper type. As the wrapper was created
before streaming queries, it does not support them. The fact that the query
result and data chunk are hidden in the wrapper prevents users from using
current and future methods, and forces us to add additional functions to support
new features. If we wanted to add support for streaming arrow requests with the
wrapper, without breaking the current code, we'd have to add
duckdb_execute_prepared_arrow_streaming and duckdb_query_arrow_streaming.

I suggest adding a function to convert the datachunk into an arrow array.
This is compatible with both types of query and should be more future-proof.

I've simplified ArrowResultWrapper, so it no longer needs to store
ClientProperties since it's already stored in QueryResult. I've added a
low-level function that converts a data chunk into and arrow array.

@Virgiel Virgiel changed the title C-API support streaming arrow query C-API: support streaming arrow query Aug 21, 2023
@Virgiel Virgiel marked this pull request as ready for review August 21, 2023 15:03
@@ -83,10 +83,21 @@ duckdb_state duckdb_query_arrow_array(duckdb_arrow result, duckdb_arrow_array *o
if (!wrapper->current_chunk || wrapper->current_chunk->size() == 0) {
return DuckDBSuccess;
}
ArrowConverter::ToArrowArray(*wrapper->current_chunk, reinterpret_cast<ArrowArray *>(*out_array), wrapper->options);
ArrowConverter::ToArrowArray(*wrapper->current_chunk, reinterpret_cast<ArrowArray *>(*out_array),
wrapper->result->client_properties);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going to use the wrapper->result, please check if it's not null first

Copy link
Author

Choose a reason for hiding this comment

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

Since checking wrapper->current-chunk before implies that it was retrieved from the query result, I think we can expect wrapper->result not to be null

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, but that's considering the current implementation, if this detail changes in the future this could lead to a crash

@github-actions github-actions bot marked this pull request as draft August 22, 2023 08:11
@Virgiel Virgiel marked this pull request as ready for review August 22, 2023 08:33
@github-actions github-actions bot marked this pull request as draft August 24, 2023 09:43
@Virgiel Virgiel marked this pull request as ready for review August 24, 2023 14:31
@github-actions github-actions bot marked this pull request as draft August 30, 2023 14:00
@Virgiel Virgiel marked this pull request as ready for review August 30, 2023 14:47
@github-actions github-actions bot marked this pull request as draft September 5, 2023 07:48
@Virgiel Virgiel marked this pull request as ready for review September 5, 2023 08:52
@Virgiel
Copy link
Author

Virgiel commented Sep 5, 2023

The last CI failure seems to be unrelated to my changes

@Mytherin Mytherin changed the base branch from main to feature November 8, 2023 12:41
@Mytherin Mytherin merged commit 358b5da into duckdb:feature Nov 8, 2023
@Mytherin
Copy link
Collaborator

Mytherin commented Nov 8, 2023

Thanks!

krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 11, 2023
Merge pull request duckdb/duckdb#9164 from Mause/feature/jdbc-uuid-param
Merge pull request duckdb/duckdb#9185 from pdet/adbc_07
Merge pull request duckdb/duckdb#9126 from Maxxen/parquet-kv-metadata
Merge pull request duckdb/duckdb#9123 from lnkuiper/parquet_schema
Merge pull request duckdb/duckdb#9086 from lnkuiper/json_inconsistent_structure
Merge pull request duckdb/duckdb#8977 from Tishj/python_readcsv_multi_v2
Merge pull request duckdb/duckdb#9279 from hawkfish/nsdate-cast
Merge pull request duckdb/duckdb#8851 from taniabogatsch/binary_lambdas
Merge pull request duckdb/duckdb#8983 from Maxxen/types/fixedsizelist
Merge pull request duckdb/duckdb#9318 from Maxxen/fix-unused
Merge pull request duckdb/duckdb#9220 from hawkfish/exclude
Merge pull request duckdb/duckdb#9230 from Maxxen/json-plan-serialization
Merge pull request duckdb/duckdb#9011 from Tmonster/add_create_statement_support_to_fuzzer
Merge pull request duckdb/duckdb#9400 from Maxxen/array-fixes
Merge pull request duckdb/duckdb#8741 from Tishj/python_import_cache_upgrade
Merge fixes
Merge pull request duckdb/duckdb#9395 from taniabogatsch/lambda-performance
Merge pull request duckdb/duckdb#9427 from Tishj/python_table_support_replacement_scan
Merge pull request duckdb/duckdb#9516 from carlopi/fixformat
Merge pull request duckdb/duckdb#9485 from Maxxen/fix-parquet-serialization
Merge pull request duckdb/duckdb#9388 from chrisiou/issue217
Merge pull request duckdb/duckdb#9565 from Maxxen/fix-array-vector-sizes
Merge pull request duckdb/duckdb#9583 from carlopi/feature
Merge pull request duckdb/duckdb#8907 from cryoEncryp/new-list-functions
Merge pull request duckdb/duckdb#8642 from Virgiel/capi-streaming-arrow
Merge pull request duckdb/duckdb#8658 from Tishj/pytype_optional
Merge pull request duckdb/duckdb#9040 from Light-City/feature/set_mg
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.

3 participants