Skip to content

Commit 68efc7b

Browse files
committed
Initialize Kernel functions
As per changes from #46261, we need to initialize Kernel library explicitly to get the functions registered
1 parent 3bc3312 commit 68efc7b

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

cpp/src/arrow/flight/sql/odbc/flight_sql/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ if(WIN32)
102102
endif()
103103

104104
target_link_libraries(arrow_odbc_spi_impl PUBLIC odbcabstraction arrow_flight_sql_shared
105-
Boost::locale)
105+
arrow_compute_shared Boost::locale)
106106

107107
# Link libraries on MINGW64 only
108108
if(MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
// under the License.
1717

1818
#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
19+
#include "arrow/compute/api.h"
1920
#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
21+
#include "arrow/flight/sql/odbc/flight_sql/utils.h"
2022
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
2123
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h"
2224
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h"
@@ -56,6 +58,8 @@ LogLevel ToLogLevel(int64_t level) {
5658
FlightSqlDriver::FlightSqlDriver()
5759
: diagnostics_("Apache Arrow", "Flight SQL", OdbcVersion::V_3), version_("0.9.0.0") {
5860
RegisterLog();
61+
// Register Kernel functions to library
62+
ThrowIfNotOK(arrow::compute::Initialize());
5963
}
6064

6165
std::shared_ptr<Connection> FlightSqlDriver::CreateConnection(OdbcVersion odbc_version) {

cpp/src/arrow/flight/sql/odbc/flight_sql/utils_test.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/calendar_utils.h"
2121

22+
#include "arrow/compute/initialize.h"
2223
#include "arrow/testing/builder.h"
2324
#include "arrow/testing/gtest_util.h"
2425
#include "arrow/testing/util.h"
@@ -27,6 +28,13 @@
2728
namespace driver {
2829
namespace flight_sql {
2930

31+
class UtilTestsWithCompute : public ::testing::Test {
32+
public:
33+
// This must be done before using the compute kernels in order to
34+
// register them to the FunctionRegistry.
35+
void SetUp() override { ASSERT_OK(arrow::compute::Initialize()); }
36+
};
37+
3038
void AssertConvertedArray(const std::shared_ptr<arrow::Array>& expected_array,
3139
const std::shared_ptr<arrow::Array>& converted_array,
3240
uint64_t size, arrow::Type::type arrow_type) {
@@ -80,7 +88,7 @@ void TestTime64ArrayConversion(const std::vector<int64_t>& input,
8088
AssertConvertedArray(expected_array, converted_array, input.size(), arrow_type);
8189
}
8290

83-
TEST(Utils, Time32ToTimeStampArray) {
91+
TEST_F(UtilTestsWithCompute, Time32ToTimeStampArray) {
8492
std::vector<int32_t> input_data = {14896, 17820};
8593

8694
const auto seconds_from_epoch = odbcabstraction::GetTodayTimeFromEpoch();
@@ -100,7 +108,7 @@ TEST(Utils, Time32ToTimeStampArray) {
100108
arrow::Type::TIMESTAMP);
101109
}
102110

103-
TEST(Utils, Time64ToTimeStampArray) {
111+
TEST_F(UtilTestsWithCompute, Time64ToTimeStampArray) {
104112
std::vector<int64_t> input_data = {1579489200000, 1646881200000};
105113

106114
const auto seconds_from_epoch = odbcabstraction::GetTodayTimeFromEpoch();
@@ -120,7 +128,7 @@ TEST(Utils, Time64ToTimeStampArray) {
120128
arrow::Type::TIMESTAMP);
121129
}
122130

123-
TEST(Utils, StringToDateArray) {
131+
TEST_F(UtilTestsWithCompute, StringToDateArray) {
124132
std::shared_ptr<arrow::Array> expected;
125133
arrow::ArrayFromVector<arrow::Date64Type, int64_t>({1579489200000, 1646881200000},
126134
&expected);
@@ -129,7 +137,7 @@ TEST(Utils, StringToDateArray) {
129137
odbcabstraction::CDataType_DATE, arrow::Type::DATE64);
130138
}
131139

132-
TEST(Utils, StringToTimeArray) {
140+
TEST_F(UtilTestsWithCompute, StringToTimeArray) {
133141
std::shared_ptr<arrow::Array> expected;
134142
arrow::ArrayFromVector<arrow::Time64Type, int64_t>(
135143
time64(arrow::TimeUnit::MICRO), {36000000000, 43200000000}, &expected);

0 commit comments

Comments
 (0)