Skip to content

Commit 48ced65

Browse files
committed
Address Sutou's comments
Put kernel registration in a testing environment
1 parent aca308f commit 48ced65

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ endif()
102102
target_link_libraries(arrow_odbc_spi_impl PUBLIC odbcabstraction arrow_flight_sql_shared
103103
arrow_compute_shared Boost::locale)
104104

105-
# Link libraries on MINGW64 only
106-
if((MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR APPLE)
105+
# Link libraries on MINGW64 and macOS
106+
if(MINGW OR APPLE)
107107
target_link_libraries(arrow_odbc_spi_impl PUBLIC ${ODBCINST})
108108
endif()
109109

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828
namespace driver {
2929
namespace flight_sql {
3030

31-
class UtilTestsWithCompute : public ::testing::Test {
31+
// A global test "environment", to ensure Arrow compute kernel functions are registered
32+
33+
class ComputeKernelEnvironment : public ::testing::Environment {
3234
public:
33-
// This must be done before using the compute kernels in order to
34-
// register them to the FunctionRegistry.
3535
void SetUp() override { ASSERT_OK(arrow::compute::Initialize()); }
3636
};
3737

38+
::testing::Environment* kernel_env =
39+
::testing::AddGlobalTestEnvironment(new ComputeKernelEnvironment);
40+
3841
void AssertConvertedArray(const std::shared_ptr<arrow::Array>& expected_array,
3942
const std::shared_ptr<arrow::Array>& converted_array,
4043
uint64_t size, arrow::Type::type arrow_type) {
@@ -88,7 +91,7 @@ void TestTime64ArrayConversion(const std::vector<int64_t>& input,
8891
AssertConvertedArray(expected_array, converted_array, input.size(), arrow_type);
8992
}
9093

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

9497
const auto seconds_from_epoch = odbcabstraction::GetTodayTimeFromEpoch();
@@ -108,7 +111,7 @@ TEST_F(UtilTestsWithCompute, Time32ToTimeStampArray) {
108111
arrow::Type::TIMESTAMP);
109112
}
110113

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

114117
const auto seconds_from_epoch = odbcabstraction::GetTodayTimeFromEpoch();
@@ -128,7 +131,7 @@ TEST_F(UtilTestsWithCompute, Time64ToTimeStampArray) {
128131
arrow::Type::TIMESTAMP);
129132
}
130133

131-
TEST_F(UtilTestsWithCompute, StringToDateArray) {
134+
TEST(Utils, StringToDateArray) {
132135
std::shared_ptr<arrow::Array> expected;
133136
arrow::ArrayFromVector<arrow::Date64Type, int64_t>({1579489200000, 1646881200000},
134137
&expected);
@@ -137,7 +140,7 @@ TEST_F(UtilTestsWithCompute, StringToDateArray) {
137140
odbcabstraction::CDataType_DATE, arrow::Type::DATE64);
138141
}
139142

140-
TEST_F(UtilTestsWithCompute, StringToTimeArray) {
143+
TEST(Utils, StringToTimeArray) {
141144
std::shared_ptr<arrow::Array> expected;
142145
arrow::ArrayFromVector<arrow::Time64Type, int64_t>(
143146
time64(arrow::TimeUnit::MICRO), {36000000000, 43200000000}, &expected);
@@ -146,15 +149,15 @@ TEST_F(UtilTestsWithCompute, StringToTimeArray) {
146149
arrow::Type::TIME64);
147150
}
148151

149-
TEST_F(UtilTestsWithCompute, ConvertSqlPatternToRegexString) {
152+
TEST(Utils, ConvertSqlPatternToRegexString) {
150153
ASSERT_EQ(std::string("XY"), ConvertSqlPatternToRegexString("XY"));
151154
ASSERT_EQ(std::string("X.Y"), ConvertSqlPatternToRegexString("X_Y"));
152155
ASSERT_EQ(std::string("X.*Y"), ConvertSqlPatternToRegexString("X%Y"));
153156
ASSERT_EQ(std::string("X%Y"), ConvertSqlPatternToRegexString("X\\%Y"));
154157
ASSERT_EQ(std::string("X_Y"), ConvertSqlPatternToRegexString("X\\_Y"));
155158
}
156159

157-
TEST_F(UtilTestsWithCompute, ConvertToDBMSVer) {
160+
TEST(Utils, ConvertToDBMSVer) {
158161
ASSERT_EQ(std::string("01.02.0003"), ConvertToDBMSVer("1.2.3"));
159162
ASSERT_EQ(std::string("01.02.0003.0"), ConvertToDBMSVer("1.2.3.0"));
160163
ASSERT_EQ(std::string("01.02.0000"), ConvertToDBMSVer("1.2"));

0 commit comments

Comments
 (0)