Skip to content

Conversation

alinaliBQ
Copy link
Contributor

@alinaliBQ alinaliBQ commented Oct 2, 2025

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

Comment on lines 22 to 23
#include <arrow/flight/types.h>
#include <boost/variant.hpp>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boost::variant is an existing dependency of flightsql-odbc. Our plan is to replace it with std::variant in future PRs

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Oct 2, 2025
@kou kou changed the title GH-46004: [C++][FlightRPC] Enable ODBC Build In C++ and Glib Workflows GH-46004: [C++][FlightRPC] Enable ODBC Build In C++ and GLib Workflows Oct 3, 2025
@@ -219,6 +219,7 @@ jobs:
ARROW_DATASET: ON
ARROW_FLIGHT: ON
ARROW_FLIGHT_SQL: ON
ARROW_FLIGHT_SQL_ODBC: ON
Copy link
Contributor Author

@alinaliBQ alinaliBQ Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alinaliBQ alinaliBQ force-pushed the gh-46004-build-odbc branch 2 times, most recently from c1d79fa to bb49757 Compare October 8, 2025 16:58
@alinaliBQ alinaliBQ changed the title GH-46004: [C++][FlightRPC] Enable ODBC Build In C++ and GLib Workflows GH-46004: [C++][FlightRPC] Enable ODBC Build In C++ Workflows Oct 8, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46004-build-odbc branch from bb49757 to 7d0c9ad Compare October 8, 2025 17:38
Enable ODBC build in Windows MSVC workflow
@alinaliBQ alinaliBQ force-pushed the gh-46004-build-odbc branch 2 times, most recently from f97a86d to 078841c Compare October 9, 2025 17:25
@alinaliBQ alinaliBQ force-pushed the gh-46004-build-odbc branch from 078841c to 83df835 Compare October 9, 2025 19:17
ODBC driver registration is required for ODBC tests (enabled in a separate PR)
@alinaliBQ alinaliBQ force-pushed the gh-46004-build-odbc branch from ec39f37 to 4d254df Compare October 9, 2025 19:49
@alinaliBQ alinaliBQ marked this pull request as ready for review October 9, 2025 20:22
@alinaliBQ
Copy link
Contributor Author

@lidavidm @kou The PR for building ODBC is ready for review. Please have a look, thanks

switch (msg) {
case WM_NCCREATE: {
_ASSERT(lparam != NULL);
assert(lparam != NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ARROW_DCHECK*() instead?

# ifdef NDEBUG
# define ARROW_DFATAL ::arrow::util::ArrowLogLevel::ARROW_WARNING
// CAUTION: DCHECK_OK() always evaluates its argument, but other DCHECK*() macros
// only do so in debug mode.
# define ARROW_DCHECK(condition) \
while (false) ARROW_IGNORE_EXPR(condition); \
while (false) ::arrow::util::detail::NullLog()
# define ARROW_DCHECK_OK(s) \
ARROW_IGNORE_EXPR(s); \
while (false) ::arrow::util::detail::NullLog()
# define ARROW_DCHECK_EQ(val1, val2) \
while (false) ARROW_IGNORE_EXPR(val1); \
while (false) ARROW_IGNORE_EXPR(val2); \
while (false) ::arrow::util::detail::NullLog()
# define ARROW_DCHECK_NE(val1, val2) \
while (false) ARROW_IGNORE_EXPR(val1); \
while (false) ARROW_IGNORE_EXPR(val2); \
while (false) ::arrow::util::detail::NullLog()
# define ARROW_DCHECK_LE(val1, val2) \
while (false) ARROW_IGNORE_EXPR(val1); \
while (false) ARROW_IGNORE_EXPR(val2); \
while (false) ::arrow::util::detail::NullLog()
# define ARROW_DCHECK_LT(val1, val2) \
while (false) ARROW_IGNORE_EXPR(val1); \
while (false) ARROW_IGNORE_EXPR(val2); \
while (false) ::arrow::util::detail::NullLog()
# define ARROW_DCHECK_GE(val1, val2) \
while (false) ARROW_IGNORE_EXPR(val1); \
while (false) ARROW_IGNORE_EXPR(val2); \
while (false) ::arrow::util::detail::NullLog()
# define ARROW_DCHECK_GT(val1, val2) \
while (false) ARROW_IGNORE_EXPR(val1); \
while (false) ARROW_IGNORE_EXPR(val2); \
while (false) ::arrow::util::detail::NullLog()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I have changed to use ARROW_DCHECK here.

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Arrow Flight SQL ODBC Driver" /v Setup /t REG_SZ /d %ODBC_AMD64% /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" /v "Apache Arrow Flight SQL ODBC Driver" /t REG_SZ /d "Installed" /f

IF !ERRORLEVEL! NEQ 0 (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
IF !ERRORLEVEL! NEQ 0 (
if !ERRORLEVEL! NEQ 0 (

BTW, is !ERRORLEVEL! still non 0 when the first reg add succeeded and the last reg add failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!ERRORLEVEL! should be reflecting on the last command executed, so yes !ERRORLEVEL! should be non zero if last reg add failed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need _amd64 in file name?

It seems that this doesn't have any amd64 specific part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that's fair, I have renamed to install_odbc


#pragma once

#if defined _WIN32 || defined _WIN64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need || defined _WIN64 here?

https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

_WIN32 Defined as 1 when the compilation target is 32-bit ARM, 64-bit ARM, x86, x64, or ARM64EC. Otherwise, undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be removed. Fixed

Comment on lines 40 to 41
# Compile entry_points.cc before odbc_api.cc due to conflict from sql.h and flight/types.h
set(ARROW_FLIGHT_SQL_ODBC_SRCS odbc_api.cc entry_points.cc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you share build log URL without this?

We may just need to disable unity build like https://github.com/apache/arrow/pull/47627/files#diff-2a4796eff3f25e1b0fd6a0db28bdea1efbc3ec69457705b1069cf70ad5355624R192-R204 does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our team discovered the build failure a while ago so I don't have the error log. I have reverted this change. If the build fails because of it then I can send the log here

- name: Register Flight SQL ODBC Driver
shell: cmd
run: |
call "cpp\src\arrow\flight\sql\odbc\install\install_amd64.cmd" ${{github.workspace}}\build\cpp\%ARROW_BUILD_TYPE%\libarrow_flight_sql_odbc.dll
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpp\src\arrow\flight\sql\odbc\script\ not ...\install\ may be better.
We will add uninstall scripts later, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I have renamed to script folder.

I am not sure if uninstall scripts are needed in this scenario and I am open to discussion. This script is for testing only. ODBC users will be able to install and uninstall the ODBC driver using a msi executable, so they won't need to use the script to install or uninstall the driver. Developers can also manually delete the driver registry if needed. This script can also be run a second time to change the registry to point to a different ODBC dll location, so the driver registry usually doesn't need to be deleted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Then how about using test\ directory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or ci\scripts\?

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Oct 10, 2025
#include "arrow/flight/sql/odbc/odbc_impl/platform.h"

#include <sys/types.h>
#include <cstdint>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this missing previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so. I recall it was causing build issues on workflows. The build works with or without this header on my local machine (Windows MSVC), but the CI builds can have problems without the header

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 10, 2025
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants