Skip to content

Commit 6a08785

Browse files
authored
GH-46004: [C++][FlightRPC] Enable ODBC Build In C++ Workflows (#47689)
### Rationale for this change Enable ODBC Build In C++ Workflows to make sure ODBC can build in CI. ### What changes are included in this PR? - Make environment variable `ARROW_FLIGHT_SQL_ODBC:ON` recognized in C++ build. - Register ODBC driver dll ### Are these changes tested? Tested in CI ### Are there any user-facing changes? No Extracted from PR #46099 * GitHub Issue: #46004 Authored-by: Alina (Xi) Li <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 7e3aad7 commit 6a08785

15 files changed

+82
-13
lines changed

.github/workflows/cpp.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ jobs:
389389
PIPX_BASE_PYTHON: ${{ steps.python-install.outputs.python-path }}
390390
run: |
391391
ci/scripts/install_gcs_testbench.sh default
392+
- name: Register Flight SQL ODBC Driver
393+
shell: cmd
394+
run: |
395+
call "cpp\src\arrow\flight\sql\odbc\tests\install_odbc.cmd" ${{ github.workspace }}\build\cpp\%ARROW_BUILD_TYPE%\libarrow_flight_sql_odbc.dll
392396
- name: Test
393397
shell: msys2 {0}
394398
run: |

ci/scripts/cpp_build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ if [ "${ARROW_ENABLE_THREADING:-ON}" = "OFF" ]; then
6464
ARROW_AZURE=OFF
6565
ARROW_FLIGHT=OFF
6666
ARROW_FLIGHT_SQL=OFF
67+
ARROW_FLIGHT_SQL_ODBC=OFF
6768
ARROW_GCS=OFF
6869
ARROW_JEMALLOC=OFF
6970
ARROW_MIMALLOC=OFF
@@ -212,6 +213,7 @@ else
212213
-DARROW_FILESYSTEM=${ARROW_FILESYSTEM:-ON} \
213214
-DARROW_FLIGHT=${ARROW_FLIGHT:-OFF} \
214215
-DARROW_FLIGHT_SQL=${ARROW_FLIGHT_SQL:-OFF} \
216+
-DARROW_FLIGHT_SQL_ODBC=${ARROW_FLIGHT_SQL_ODBC:-OFF} \
215217
-DARROW_FUZZING=${ARROW_FUZZING:-OFF} \
216218
-DARROW_GANDIVA_PC_CXX_FLAGS=${ARROW_GANDIVA_PC_CXX_FLAGS:-} \
217219
-DARROW_GANDIVA=${ARROW_GANDIVA:-OFF} \

cpp/cmake_modules/DefineOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ endmacro()
108108

109109
macro(resolve_option_dependencies)
110110
# Arrow Flight SQL ODBC is available only for Windows for now.
111-
if(NOT MSVC_TOOLCHAIN)
111+
if(NOT WIN32)
112112
set(ARROW_FLIGHT_SQL_ODBC OFF)
113113
endif()
114114
if(MSVC_TOOLCHAIN)

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ if(ARROW_USE_BOOST)
12741274
endif()
12751275
if(ARROW_BOOST_REQUIRE_LIBRARY)
12761276
set(ARROW_BOOST_COMPONENTS filesystem system)
1277-
if(ARROW_FLIGHT_SQL_ODBC AND MSVC)
1277+
if(ARROW_FLIGHT_SQL_ODBC)
12781278
list(APPEND ARROW_BOOST_COMPONENTS locale)
12791279
endif()
12801280
if(ARROW_ENABLE_THREADING)

cpp/src/arrow/flight/sql/odbc/odbc_impl/accessors/string_array_accessor.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace arrow::flight::sql::odbc {
2525
namespace {
2626

27-
#if defined _WIN32 || defined _WIN64
27+
#if defined _WIN32
2828
std::string Utf8ToCLocale(const char* utf8_str, int len) {
2929
thread_local boost::locale::generator g;
3030
g.locale_cache_enabled(true);
@@ -36,7 +36,7 @@ std::string Utf8ToCLocale(const char* utf8_str, int len) {
3636
template <typename CHAR_TYPE>
3737
inline RowStatus MoveSingleCellToCharBuffer(
3838
std::vector<uint8_t>& buffer, int64_t& last_retrieved_arrow_row,
39-
#if defined _WIN32 || defined _WIN64
39+
#if defined _WIN32
4040
std::string& clocale_str,
4141
#endif
4242
ColumnBinding* binding, StringArray* array, int64_t arrow_row, int64_t i,
@@ -57,7 +57,7 @@ inline RowStatus MoveSingleCellToCharBuffer(
5757
value = buffer.data();
5858
size_in_bytes = buffer.size();
5959
} else {
60-
#if defined _WIN32 || defined _WIN64
60+
#if defined _WIN32
6161
// Convert to C locale string
6262
if (last_retrieved_arrow_row != arrow_row) {
6363
clocale_str = Utf8ToCLocale(raw_value, raw_value_length);
@@ -124,7 +124,7 @@ RowStatus StringArrayFlightSqlAccessor<TARGET_TYPE, CHAR_TYPE>::MoveSingleCellIm
124124
ColumnBinding* binding, int64_t arrow_row, int64_t i, int64_t& value_offset,
125125
bool update_value_offset, Diagnostics& diagnostics) {
126126
return MoveSingleCellToCharBuffer<CHAR_TYPE>(buffer_, last_arrow_row_,
127-
#if defined _WIN32 || defined _WIN64
127+
#if defined _WIN32
128128
clocale_str_,
129129
#endif
130130
binding, this->GetArray(), arrow_row, i,

cpp/src/arrow/flight/sql/odbc/odbc_impl/accessors/string_array_accessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class StringArrayFlightSqlAccessor
4141

4242
private:
4343
std::vector<uint8_t> buffer_;
44-
#if defined _WIN32 || defined _WIN64
44+
#if defined _WIN32
4545
std::string clocale_str_;
4646
#endif
4747
int64_t last_arrow_row_;

cpp/src/arrow/flight/sql/odbc/odbc_impl/accessors/string_array_accessor_test.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ TEST(StringArrayAccessor, Test_CDataType_WCHAR_Truncation) {
126126
ColumnBinding binding(CDataType_WCHAR, 0, 0, buffer.data(), max_str_len,
127127
str_len_buffer.data());
128128

129-
std::basic_stringstream<uint8_t> ss;
130129
int64_t value_offset = 0;
131130

132131
// Construct the whole string by concatenating smaller chunks from

cpp/src/arrow/flight/sql/odbc/odbc_impl/address_info.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "arrow/flight/sql/odbc/odbc_impl/platform.h"
2323

2424
#include <sys/types.h>
25+
#include <cstdint>
2526
#if !_WIN32
2627
# include <netdb.h>
2728
#endif

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ boost::optional<int32_t> FlightSqlConnection::GetStringColumnLength(
212212
}
213213

214214
bool FlightSqlConnection::GetUseWideChar(const ConnPropertyMap& conn_property_map) {
215-
#if defined _WIN32 || defined _WIN64
215+
#if defined _WIN32
216216
// Windows should use wide chars by default
217217
bool default_value = true;
218218
#else

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_statement_get_columns.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
#pragma once
19+
1820
#include <optional>
1921
#include "arrow/array/builder_binary.h"
2022
#include "arrow/array/builder_primitive.h"

0 commit comments

Comments
 (0)