33#include " PandasDataFrameBuilder.h"
44#include " ChunkCollectorOutputFormat.h"
55#include " PythonImporter.h"
6- #include " PythonTableCache.h"
76#include " StoragePython.h"
87
98#include < pybind11/detail/non_limited_api.h>
@@ -274,13 +273,14 @@ query_result * connection_wrapper::query(const std::string & query_str, const st
274273
275274 auto * result = chdb_query_n (*conn, query_str.data (), query_str.size (), format.data (), format.size ());
276275
277- auto error_msg = CHDB::chdb_result_error_string (result);
276+ const auto & error_msg = CHDB::chdb_result_error_string (result);
278277 if (!error_msg.empty ())
279278 {
280279 std::string msg_copy (error_msg);
281280 chdb_destroy_query_result (result);
282281 throw std::runtime_error (msg_copy);
283282 }
283+
284284 return new query_result (result, false );
285285}
286286
@@ -298,7 +298,7 @@ py::object connection_wrapper::query_df(const std::string & query_str)
298298
299299 result = chdb_query_n (*conn, query_str.data (), query_str.size (), format.data (), format.size ());
300300
301- auto error_msg = CHDB::chdb_result_error_string (result);
301+ const auto & error_msg = CHDB::chdb_result_error_string (result);
302302 if (!error_msg.empty ())
303303 {
304304 std::string msg_copy (error_msg);
@@ -322,7 +322,7 @@ streaming_query_result * connection_wrapper::send_query(const std::string & quer
322322 CHDB::cachePythonTablesFromQuery (reinterpret_cast <chdb_conn *>(*conn), query_str);
323323 py::gil_scoped_release release;
324324 auto * result = chdb_stream_query_n (*conn, query_str.data (), query_str.size (), format.data (), format.size ());
325- auto error_msg = CHDB::chdb_result_error_string (result);
325+ const auto & error_msg = CHDB::chdb_result_error_string (result);
326326 if (!error_msg.empty ())
327327 {
328328 std::string msg_copy (error_msg);
@@ -342,7 +342,7 @@ query_result * connection_wrapper::streaming_fetch_result(streaming_query_result
342342
343343 auto * result = chdb_stream_fetch_result (*conn, streaming_result->get_result ());
344344
345- const auto error_msg = CHDB::chdb_result_error_string (result);
345+ const auto & error_msg = CHDB::chdb_result_error_string (result);
346346 if (!error_msg.empty ())
347347 {
348348 std::string msg_copy (error_msg);
@@ -359,30 +359,29 @@ py::object connection_wrapper::streaming_fetch_df(streaming_query_result * strea
359359 return py::none ();
360360
361361 chdb_result * result = nullptr ;
362- CHDB::ChunkQueryResult * chunk_result = nullptr ;
362+ CHDB::DataFrameQueryResult * chunk_result = nullptr ;
363363
364364 {
365365 py::gil_scoped_release release;
366366
367- result = chdb_stream_fetch_result (*conn, streaming_result->get_result ());
367+ result = chdb_stream_fetch_result (*conn, streaming_result->get_result ());
368368
369- auto error_msg = CHDB::chdb_result_error_string (result);
369+ const auto & error_msg = CHDB::chdb_result_error_string (result);
370370 if (!error_msg.empty ())
371371 {
372372 std::string msg_copy (error_msg);
373373 chdb_destroy_query_result (result);
374374 throw std::runtime_error (msg_copy);
375375 }
376376
377- if (!(chunk_result = dynamic_cast <CHDB::ChunkQueryResult *>(reinterpret_cast <CHDB::QueryResult*>(result))))
378- throw std::runtime_error (" Expected ChunkQueryResult for dataframe format" );
377+ if (!(chunk_result = dynamic_cast <CHDB::DataFrameQueryResult *>(reinterpret_cast <CHDB::QueryResult*>(result))))
378+ throw std::runtime_error (" Expected DataFrameQueryResult for dataframe format" );
379379 }
380380
381- CHDB::PandasDataFrameBuilder builder (*chunk_result);
382- auto df = builder.getDataFrame ();
381+ py::handle df_handle = chunk_result->dataframe ;
383382 chdb_destroy_query_result (result);
384383
385- return df ;
384+ return py::reinterpret_steal<py::object>(df_handle) ;
386385}
387386
388387void connection_wrapper::streaming_cancel_query (streaming_query_result * streaming_result)
0 commit comments