You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alinaliBQ (via GitHub)" <gi...@apache.org> on 2025/09/05 19:30:52 UTC

[PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

alinaliBQ opened a new pull request, #47517:
URL: https://github.com/apache/arrow/pull/47517

   ### Rationale for this change
   Add initial framework for building an ODBC driver dll
   
   ### What changes are included in this PR?
   - initial Flight SQL ODBC framework
   
   ### Are these changes tested?
   - Yes, on local Windows environment
   
   ### Are there any user-facing changes?
   - None


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2328577652


##########
cpp/src/arrow/flight/sql/odbc/entry_points.cc:
##########
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// platform.h includes windows.h, so it needs to be included first
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif

Review Comment:
   Do we need this?



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
+  elseif(MINGW)
+    set(ODBCINST odbccp32 shlwapi)
+  endif()
+elseif(APPLE)
+  set(ODBCINST iodbcinst)
+else()
+  set(ODBCINST odbcinst)
+endif()
+
+include(FetchContent)
+fetchcontent_declare(spdlog
+                     URL https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.zip
+                         CONFIGURE_COMMAND
+                         ""
+                         BUILD_COMMAND
+                         "")
+fetchcontent_makeavailable(spdlog)

Review Comment:
   Can we use `arrow/util/logging.h` instead?



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)

Review Comment:
   Could you use `target_compile_definitions()` because `add_compile_definitions()`'s scope is directory? We should not use directory scope commands such as `add_compile_definitions()` and `include_directories()` for newly written code.



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"
+
+// odbc_api includes windows.h, which needs to be put behind winsock2.h.

Review Comment:
   ```suggestion
   // odbc_api.h includes windows.h, which needs to be put behind winsock2.h.
   ```



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"
+
+// odbc_api includes windows.h, which needs to be put behind winsock2.h.
+// odbc_environment.h includes winsock2.h

Review Comment:
   Who does include `odbc_environment.h`?



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)

Review Comment:
   Why is `legacy_stdio_definitions` needed?



##########
cpp/src/arrow/flight/sql/odbc/entry_points.cc:
##########
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// platform.h includes windows.h, so it needs to be included first
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+#include "arrow/flight/sql/odbc/odbc_api.h"
+#include "arrow/flight/sql/odbc/visibility.h"
+
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+
+SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) {
+  return SQL_INVALID_HANDLE;
+}

Review Comment:
   Do we need both of the top-level `SQLAllocHandle()` and `arrow::SQLAllocHandle()`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "alinaliBQ (via GitHub)" <gi...@apache.org>.
alinaliBQ commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2350102236


##########
cpp/src/arrow/flight/sql/odbc/odbc_api.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+//  @file odbc_api.h
+//
+//  Define internal ODBC API function headers.
+namespace arrow {

Review Comment:
   Yup good point. Updated code



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)

Review Comment:
   Sure, I changed to use `target_compile_definitions`



##########
cpp/src/arrow/flight/sql/odbc/entry_points.cc:
##########
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// platform.h includes windows.h, so it needs to be included first
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+#include "arrow/flight/sql/odbc/odbc_api.h"
+#include "arrow/flight/sql/odbc/visibility.h"
+
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+
+SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) {
+  return SQL_INVALID_HANDLE;
+}

Review Comment:
   Yes. In upcoming PRs, we plan to change it to look like:
   ```
   SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) {
     return arrow::flight::sql::odbc::SQLAllocHandle(...);
   }
   ```
   I have separate the actual implementation of `SQLAllocHandle` to make this PR smaller



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+//  @file odbc_api.h

Review Comment:
   fixed



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"

Review Comment:
   These includes will be used in upcoming PRs as they are needed in branch at https://github.com/apache/arrow/pull/46099, is it okay to keep these includes there? Currently most of them are not used in this PR. 



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"
+
+// odbc_api includes windows.h, which needs to be put behind winsock2.h.
+// odbc_environment.h includes winsock2.h

Review Comment:
   `odbc_environment.h` is a header included by `odbc_api.cc`. I have adjusted the comment order to make it clearer



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+//  @file odbc_api.h
+//
+//  Define internal ODBC API function headers.

Review Comment:
   yes, it is internal. Renamed the file



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)

Review Comment:
   `legacy_stdio_definitions` is needed to resolve this error:
   ```
   odbccp32.lib(dllload.obj) : error LNK2019: unresolved external symbol _vsnwprintf_s referenced in function StringCchPrintfW
   ```
   I think it is because odbccp32.lib are expecting these legacy symbols



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
+  elseif(MINGW)
+    set(ODBCINST odbccp32 shlwapi)
+  endif()
+elseif(APPLE)
+  set(ODBCINST iodbcinst)
+else()
+  set(ODBCINST odbcinst)
+endif()
+
+include(FetchContent)
+fetchcontent_declare(spdlog
+                     URL https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.zip
+                         CONFIGURE_COMMAND
+                         ""
+                         BUILD_COMMAND
+                         "")
+fetchcontent_makeavailable(spdlog)

Review Comment:
   Yes. Let me look into this



##########
cpp/src/arrow/flight/sql/odbc/entry_points.cc:
##########
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// platform.h includes windows.h, so it needs to be included first
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif

Review Comment:
   Yes, this is needed by the ODBC API definitions



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"
+
+// odbc_api includes windows.h, which needs to be put behind winsock2.h.

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2350343026


##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"

Review Comment:
   Ah ok, that wasn't clear, that sounds fine then.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2326680110


##########
cpp/src/arrow/flight/sql/odbc/odbc_api.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+//  @file odbc_api.h
+//
+//  Define internal ODBC API function headers.

Review Comment:
   If this is an internal header, can we name it as `odbc_api_internal.h` or similar?



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"

Review Comment:
   Are most of these includes even used?



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+//  @file odbc_api.h

Review Comment:
   We usually use `\file` doxygen style.



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqltypes.h>
+#include <sqlucode.h>
+
+//  @file odbc_api.h
+//
+//  Define internal ODBC API function headers.
+namespace arrow {

Review Comment:
   Can it be in an ODBC-specific namespace? `arrow::flight::sql::odbc`? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #47517:
URL: https://github.com/apache/arrow/pull/47517#issuecomment-3259509830

   :warning: GitHub issue #47516 **has been automatically assigned in GitHub** to PR creator.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "alinaliBQ (via GitHub)" <gi...@apache.org>.
alinaliBQ commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2377218040


##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
+  elseif(MINGW)
+    set(ODBCINST odbccp32 shlwapi)
+  endif()
+elseif(APPLE)
+  set(ODBCINST iodbcinst)
+else()
+  set(ODBCINST odbcinst)
+endif()
+
+include(FetchContent)
+fetchcontent_declare(spdlog
+                     URL https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.zip
+                         CONFIGURE_COMMAND
+                         ""
+                         BUILD_COMMAND
+                         "")
+fetchcontent_makeavailable(spdlog)

Review Comment:
   @kou I have raised PR: https://github.com/apache/arrow/pull/47645 for this change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "alinaliBQ (via GitHub)" <gi...@apache.org>.
alinaliBQ commented on PR #47517:
URL: https://github.com/apache/arrow/pull/47517#issuecomment-3259819778

   @lidavidm @kou Please review this PR, it is extracted from #46099 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou merged PR #47517:
URL: https://github.com/apache/arrow/pull/47517


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #47517:
URL: https://github.com/apache/arrow/pull/47517#issuecomment-3359025170

   After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 16ceade8f8b6a2720acf028ca3b6352000c60cdb.
   
   There were no benchmark performance regressions. 🎉
   
   The [full Conbench report](https://github.com/apache/arrow/runs/51763642287) has more details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "alinaliBQ (via GitHub)" <gi...@apache.org>.
alinaliBQ commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2395495098


##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,11 +15,64 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_custom_target(arrow_flight_sql_odbc)
-
 # Use C++ 20 for ODBC and its subdirectory
 # GH-44792: Arrow will switch to C++ 20
 set(CMAKE_CXX_STANDARD 20)
 
+add_custom_target(arrow_flight_sql_odbc)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
+  elseif(MINGW)
+    set(ODBCINST odbccp32 shlwapi)
+  endif()
+elseif(APPLE)
+  set(ODBCINST iodbcinst)
+else()
+  set(ODBCINST odbcinst)
+endif()
+
 add_subdirectory(flight_sql)
 add_subdirectory(odbcabstraction)
+
+arrow_install_all_headers("arrow/flight/sql/odbc")
+
+set(ARROW_FLIGHT_SQL_ODBC_SRCS entry_points.cc odbc_api.cc)
+
+if(WIN32)
+  list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def)
+endif()
+
+add_arrow_lib(arrow_flight_sql_odbc
+              CMAKE_PACKAGE_NAME
+              ArrowFlightSqlOdbc
+              PKG_CONFIG_NAME
+              arrow-flight-sql-odbc
+              OUTPUTS
+              ARROW_FLIGHT_SQL_ODBC_LIBRARIES
+              SOURCES
+              ${ARROW_FLIGHT_SQL_ODBC_SRCS}
+              DEPENDENCIES
+              arrow_flight_sql
+              DEFINITIONS
+              FMT_HEADER_ONLY
+              SHARED_LINK_FLAGS
+              ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
+              SHARED_LINK_LIBS
+              arrow_flight_sql_shared
+              SHARED_INSTALL_INTERFACE_LIBS
+              ArrowFlight::arrow_flight_sql_shared
+              STATIC_LINK_LIBS
+              arrow_flight_sql_static
+              STATIC_INSTALL_INTERFACE_LIBS
+              ArrowFlight::arrow_flight_sql_static
+              SHARED_PRIVATE_LINK_LIBS
+              ${ODBC_LIBRARIES}

Review Comment:
   Sure, fixed



##########
cpp/src/arrow/flight/sql/odbc/odbc_api_internal.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif

Review Comment:
   Sure, that's reasonable to use. I fixed it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "alinaliBQ (via GitHub)" <gi...@apache.org>.
alinaliBQ commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2389231589


##########
cpp/submodules/parquet-testing:
##########


Review Comment:
   let me undo this change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-47516: [C++][FlightRPC] Initial ODBC driver framework [arrow]

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2389635598


##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)

Review Comment:
   I see.



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"
+
+// odbc_api includes windows.h, which needs to be put behind winsock2.h.
+// odbc_environment.h includes winsock2.h

Review Comment:
   Ah, sorry. I missed `#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"` in the above `#include`s.
   



##########
cpp/src/arrow/flight/sql/odbc/odbc_api_internal.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif

Review Comment:
   Should we use `#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"` instead? It seems that `platform.h` defines some macros before including `windows.h`.



##########
cpp/src/arrow/flight/sql/odbc/entry_points.cc:
##########
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// platform.h includes windows.h, so it needs to be included first
+#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif

Review Comment:
   It seems that `#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"` includes `windows.h`.



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,11 +15,64 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_custom_target(arrow_flight_sql_odbc)
-
 # Use C++ 20 for ODBC and its subdirectory
 # GH-44792: Arrow will switch to C++ 20
 set(CMAKE_CXX_STANDARD 20)
 
+add_custom_target(arrow_flight_sql_odbc)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
+  elseif(MINGW)
+    set(ODBCINST odbccp32 shlwapi)
+  endif()
+elseif(APPLE)
+  set(ODBCINST iodbcinst)
+else()
+  set(ODBCINST odbcinst)
+endif()
+
 add_subdirectory(flight_sql)
 add_subdirectory(odbcabstraction)
+
+arrow_install_all_headers("arrow/flight/sql/odbc")
+
+set(ARROW_FLIGHT_SQL_ODBC_SRCS entry_points.cc odbc_api.cc)
+
+if(WIN32)
+  list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def)
+endif()
+
+add_arrow_lib(arrow_flight_sql_odbc
+              CMAKE_PACKAGE_NAME
+              ArrowFlightSqlOdbc
+              PKG_CONFIG_NAME
+              arrow-flight-sql-odbc
+              OUTPUTS
+              ARROW_FLIGHT_SQL_ODBC_LIBRARIES
+              SOURCES
+              ${ARROW_FLIGHT_SQL_ODBC_SRCS}
+              DEPENDENCIES
+              arrow_flight_sql
+              DEFINITIONS
+              FMT_HEADER_ONLY
+              SHARED_LINK_FLAGS
+              ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
+              SHARED_LINK_LIBS
+              arrow_flight_sql_shared
+              SHARED_INSTALL_INTERFACE_LIBS
+              ArrowFlight::arrow_flight_sql_shared
+              STATIC_LINK_LIBS
+              arrow_flight_sql_static
+              STATIC_INSTALL_INTERFACE_LIBS
+              ArrowFlight::arrow_flight_sql_static
+              SHARED_PRIVATE_LINK_LIBS
+              ${ODBC_LIBRARIES}

Review Comment:
   Could you use CMake target as much as possible?
   
   ```suggestion
                 ODBC::ODBC
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org