Skip to content

Commit

Permalink
Move arrow module into main python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
xhochy committed Aug 28, 2024
1 parent eae9cea commit d95284c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
34 changes: 0 additions & 34 deletions cpp/turbodbc_arrow/Library/src/python_bindings.cpp

This file was deleted.

25 changes: 25 additions & 0 deletions cpp/turbodbc_python/Library/src/python_bindings/module.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#include <turbodbc_arrow/arrow_result_set.h>
#include <turbodbc_arrow/set_arrow_parameters.h>
#include <turbodbc/cursor.h>

#include <pybind11/pybind11.h>

namespace turbodbc { namespace bindings {
Expand All @@ -19,6 +23,20 @@ namespace result_sets {
void determine_parameter_type_init();
}

namespace {

turbodbc_arrow::arrow_result_set make_arrow_result_set(std::shared_ptr<turbodbc::result_sets::result_set> result_set_pointer,
bool strings_as_dictionary, bool adaptive_integers)
{
return turbodbc_arrow::arrow_result_set(*result_set_pointer, strings_as_dictionary, adaptive_integers);
}

void set_arrow_parameters(turbodbc::cursor & cursor, pybind11::object const & pyarrow_table)
{
turbodbc_arrow::set_arrow_parameters(cursor.get_command()->get_parameters(), pyarrow_table);
}

}

using namespace turbodbc;

Expand All @@ -37,4 +55,11 @@ PYBIND11_MODULE(turbodbc_intern, module)
bindings::for_options(module);
bindings::for_python_result_set(module);
bindings::for_python_parameter_set(module);

pybind11::class_<turbodbc_arrow::arrow_result_set>(module, "ArrowResultSet")
.def("fetch_all", &turbodbc_arrow::arrow_result_set::fetch_all)
.def("fetch_next_batch", &turbodbc_arrow::arrow_result_set::fetch_next_batch);

module.def("make_arrow_result_set", make_arrow_result_set);
module.def("set_arrow_parameters", set_arrow_parameters);
}
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ py.extension_module(
'cpp/turbodbc_numpy/Library/src/string_column.cpp',
'cpp/turbodbc_numpy/Library/src/unicode_column.cpp',
'cpp/turbodbc_arrow/Library/src/arrow_result_set.cpp',
'cpp/turbodbc_arrow/Library/src/python_bindings.cpp',
'cpp/turbodbc_arrow/Library/src/set_arrow_parameters.cpp',
],
dependencies: [unixodbc, np_dep, pa_dep, arrow, arrow_python, simdutf],
Expand Down

0 comments on commit d95284c

Please sign in to comment.