File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1309,6 +1309,19 @@ class PreparedStatement {
13091309 using WriteFunc = std::add_pointer<arrow::Status(void *)>::type;
13101310 arrow::Status select (WriteFunc write, void * writeData)
13111311 {
1312+ if (parameters_.empty ())
1313+ {
1314+ auto result = SPI_execute (query_.c_str (), false , 0 );
1315+ if (result <= 0 )
1316+ {
1317+ return arrow::Status::Invalid (" failed to run a query: " ,
1318+ SPI_result_code_string (result),
1319+ " : " ,
1320+ query_);
1321+ }
1322+ return write (writeData);
1323+ }
1324+
13121325 for (const auto & recordBatch : parameters_)
13131326 {
13141327 SPIExecuteOptions options = {};
Original file line number Diff line number Diff line change @@ -114,6 +114,22 @@ def test_select_prepare
114114 end
115115 end
116116
117+ def test_select_prepare_without_parameters
118+ unless flight_sql_client . respond_to? ( :prepare )
119+ omit ( "red-arrow-flight-sql 14.0.0 or later is required" )
120+ end
121+
122+ flight_sql_client . prepare ( "SELECT 29 AS value" , @options ) do |statement |
123+ info = statement . execute ( @options )
124+ assert_equal ( Arrow ::Schema . new ( value : :int32 ) ,
125+ info . get_schema )
126+ endpoint = info . endpoints . first
127+ reader = flight_sql_client . do_get ( endpoint . ticket , @options )
128+ assert_equal ( Arrow ::Table . new ( value : Arrow ::Int32Array . new ( [ 29 ] ) ) ,
129+ reader . read_all )
130+ end
131+ end
132+
117133 def test_select_from
118134 run_sql ( "CREATE TABLE data (value integer)" )
119135 run_sql ( "INSERT INTO data VALUES (1), (-2), (3)" )
You can’t perform that action at this time.
0 commit comments