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

Bump ADBC to v0.7 #9185

Merged
merged 6 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check for too many parameters on adbc, move adbc tests to adbc folder
  • Loading branch information
pdet committed Oct 3, 2023
commit ede8d7e35a66c90c7b90097789c66fb5a34390c5
10 changes: 10 additions & 0 deletions src/common/adbc/adbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
#include "duckdb/common/arrow/arrow_wrapper.hpp"
#include "duckdb/common/arrow/nanoarrow/nanoarrow.hpp"

#include "duckdb/main/capi/capi_internal.hpp"

#ifndef DUCKDB_AMALGAMATION
#include "duckdb/main/connection.hpp"
#endif

#include "duckdb/common/adbc/single_batch_array_stream.hpp"

#include "duckdb/common/adbc/options.h"
#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -762,6 +765,9 @@ AdbcStatusCode StatementExecuteQuery(struct AdbcStatement *statement, struct Arr
return ADBC_STATUS_INVALID_ARGUMENT;
}
duckdb::unique_ptr<duckdb::DataChunk> chunk;
auto prepared_statement_params =
reinterpret_cast<duckdb::PreparedStatementWrapper *>(wrapper->statement)->statement->n_param;

while ((chunk = result->Fetch()) != nullptr) {
if (chunk->size() == 0) {
SetError(error, "Please provide a non-empty chunk to be bound");
Expand All @@ -772,6 +778,10 @@ AdbcStatusCode StatementExecuteQuery(struct AdbcStatement *statement, struct Arr
SetError(error, "Binding multiple rows at once is not supported yet");
return ADBC_STATUS_NOT_IMPLEMENTED;
}
if (chunk->ColumnCount() > prepared_statement_params) {
SetError(error, "Input data has more column than prepared statement has parameters");
return ADBC_STATUS_INVALID_ARGUMENT;
}
duckdb_clear_bindings(wrapper->statement);
for (idx_t col_idx = 0; col_idx < chunk->ColumnCount(); col_idx++) {
auto val = chunk->GetValue(col_idx, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# When testing local, if you build via BUILD_PYTHON=1 make, you need to manually set up the
# dylib duckdb path.
driver_path = duckdb.duckdb.__file__
driver_path = '/Users/holanda/Documents/Projects/duckdb/build/debug/src/libduckdb.dylib'


@pytest.fixture
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_insertion(duck_conn):

def test_read(duck_conn):
with duck_conn.cursor() as cursor:
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data", "category.csv")
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "data", "category.csv")
cursor.execute(f"SELECT * FROM '{filename}'")
assert cursor.fetch_arrow_table().to_pydict() == {
"CATEGORY_ID": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
Expand Down
5 changes: 4 additions & 1 deletion tools/pythonpkg/tests/fast/adbc/test_statement_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ def test_too_many_parameters(self):
data._export_to_c(array.address, schema.address)
statement.bind(array, schema)

with pytest.raises(adbc_driver_manager.ProgrammingError, match="INVALID_ARGUMENT"):
with pytest.raises(
adbc_driver_manager.ProgrammingError,
match="Input data has more column than prepared statement has parameters",
):
res, _ = statement.execute_query()

def test_not_enough_parameters(self):
Expand Down