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"
2728namespace driver {
2829namespace 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+
3038void 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);
@@ -138,15 +146,15 @@ TEST(Utils, StringToTimeArray) {
138146 arrow::Type::TIME64);
139147}
140148
141- TEST (Utils , ConvertSqlPatternToRegexString) {
149+ TEST_F (UtilTestsWithCompute , ConvertSqlPatternToRegexString) {
142150 ASSERT_EQ (std::string (" XY" ), ConvertSqlPatternToRegexString (" XY" ));
143151 ASSERT_EQ (std::string (" X.Y" ), ConvertSqlPatternToRegexString (" X_Y" ));
144152 ASSERT_EQ (std::string (" X.*Y" ), ConvertSqlPatternToRegexString (" X%Y" ));
145153 ASSERT_EQ (std::string (" X%Y" ), ConvertSqlPatternToRegexString (" X\\ %Y" ));
146154 ASSERT_EQ (std::string (" X_Y" ), ConvertSqlPatternToRegexString (" X\\ _Y" ));
147155}
148156
149- TEST (Utils , ConvertToDBMSVer) {
157+ TEST_F (UtilTestsWithCompute , ConvertToDBMSVer) {
150158 ASSERT_EQ (std::string (" 01.02.0003" ), ConvertToDBMSVer (" 1.2.3" ));
151159 ASSERT_EQ (std::string (" 01.02.0003.0" ), ConvertToDBMSVer (" 1.2.3.0" ));
152160 ASSERT_EQ (std::string (" 01.02.0000" ), ConvertToDBMSVer (" 1.2" ));
0 commit comments