Skip to content

Commit

Permalink
Fix DLL linkage on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm committed Jun 24, 2022
1 parent 2bcdd03 commit f4244e7
Show file tree
Hide file tree
Showing 2 changed files with 288 additions and 0 deletions.
286 changes: 286 additions & 0 deletions recipe/0001-ARROW-16902-C-FlightRPC-Fix-DLL-linkage-in-Flight-SQ.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
From dddea1e7df26833ec0df30e09ea08c765a8c52a5 Mon Sep 17 00:00:00 2001
From: David Li <li.davidm96@gmail.com>
Date: Fri, 24 Jun 2022 15:18:19 -0400
Subject: [PATCH] ARROW-16902: [C++][FlightRPC] Fix DLL linkage in Flight SQL

---
cpp/src/arrow/flight/sql/CMakeLists.txt | 3 ++
cpp/src/arrow/flight/sql/client.h | 4 +--
cpp/src/arrow/flight/sql/column_metadata.h | 5 +--
cpp/src/arrow/flight/sql/server.h | 37 ++++++++++----------
cpp/src/arrow/flight/sql/sql_info_internal.h | 3 +-
cpp/src/arrow/flight/sql/types.h | 5 +--
6 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/cpp/src/arrow/flight/sql/CMakeLists.txt b/cpp/src/arrow/flight/sql/CMakeLists.txt
index 6efe6e76b..31cebd285 100644
--- a/cpp/src/arrow/flight/sql/CMakeLists.txt
+++ b/cpp/src/arrow/flight/sql/CMakeLists.txt
@@ -60,6 +60,9 @@ add_arrow_lib(arrow_flight_sql
arrow_flight_shared
STATIC_LINK_LIBS
arrow_flight_static)
+foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_LIBRARIES})
+ target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING)
+endforeach()

if(ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
set(ARROW_FLIGHT_SQL_TEST_LINK_LIBS arrow_flight_sql_static
diff --git a/cpp/src/arrow/flight/sql/client.h b/cpp/src/arrow/flight/sql/client.h
index 78c162e4c..0b83a6edc 100644
--- a/cpp/src/arrow/flight/sql/client.h
+++ b/cpp/src/arrow/flight/sql/client.h
@@ -35,7 +35,7 @@ class PreparedStatement;
/// \brief Flight client with Flight SQL semantics.
///
/// Wraps a Flight client to provide the Flight SQL RPC calls.
-class ARROW_EXPORT FlightSqlClient {
+class ARROW_FLIGHT_EXPORT FlightSqlClient {
friend class PreparedStatement;

private:
@@ -202,7 +202,7 @@ class ARROW_EXPORT FlightSqlClient {
};

/// \brief A prepared statement that can be executed.
-class ARROW_EXPORT PreparedStatement {
+class ARROW_FLIGHT_EXPORT PreparedStatement {
public:
/// \brief Create a new prepared statement. However, applications
/// should generally use FlightSqlClient::Prepare.
diff --git a/cpp/src/arrow/flight/sql/column_metadata.h b/cpp/src/arrow/flight/sql/column_metadata.h
index 08e7c64ae..7d6c74e01 100644
--- a/cpp/src/arrow/flight/sql/column_metadata.h
+++ b/cpp/src/arrow/flight/sql/column_metadata.h
@@ -19,6 +19,7 @@

#include <string>

+#include "arrow/flight/visibility.h"
#include "arrow/util/key_value_metadata.h"

namespace arrow {
@@ -26,7 +27,7 @@ namespace flight {
namespace sql {

/// \brief Helper class to set column metadata.
-class ColumnMetadata {
+class ARROW_FLIGHT_EXPORT ColumnMetadata {
private:
std::shared_ptr<const arrow::KeyValueMetadata> metadata_map_;

@@ -114,7 +115,7 @@ class ColumnMetadata {
const std::shared_ptr<const arrow::KeyValueMetadata>& metadata_map() const;

/// \brief A builder class to construct the ColumnMetadata object.
- class ColumnMetadataBuilder {
+ class ARROW_FLIGHT_EXPORT ColumnMetadataBuilder {
public:
friend class ColumnMetadata;

diff --git a/cpp/src/arrow/flight/sql/server.h b/cpp/src/arrow/flight/sql/server.h
index 4e6ddce23..1875ec8f7 100644
--- a/cpp/src/arrow/flight/sql/server.h
+++ b/cpp/src/arrow/flight/sql/server.h
@@ -39,43 +39,43 @@ namespace sql {
/// @{

/// \brief A SQL query.
-struct StatementQuery {
+struct ARROW_FLIGHT_EXPORT StatementQuery {
/// \brief The SQL query.
std::string query;
};

/// \brief A SQL update query.
-struct StatementUpdate {
+struct ARROW_FLIGHT_EXPORT StatementUpdate {
/// \brief The SQL query.
std::string query;
};

/// \brief A request to execute a query.
-struct StatementQueryTicket {
+struct ARROW_FLIGHT_EXPORT StatementQueryTicket {
/// \brief The server-generated opaque identifier for the query.
std::string statement_handle;
};

/// \brief A prepared query statement.
-struct PreparedStatementQuery {
+struct ARROW_FLIGHT_EXPORT PreparedStatementQuery {
/// \brief The server-generated opaque identifier for the statement.
std::string prepared_statement_handle;
};

/// \brief A prepared update statement.
-struct PreparedStatementUpdate {
+struct ARROW_FLIGHT_EXPORT PreparedStatementUpdate {
/// \brief The server-generated opaque identifier for the statement.
std::string prepared_statement_handle;
};

/// \brief A request to fetch server metadata.
-struct GetSqlInfo {
+struct ARROW_FLIGHT_EXPORT GetSqlInfo {
/// \brief A list of metadata IDs to fetch.
std::vector<int32_t> info;
};

/// \brief A request to list database schemas.
-struct GetDbSchemas {
+struct ARROW_FLIGHT_EXPORT GetDbSchemas {
/// \brief An optional database catalog to filter on.
util::optional<std::string> catalog;
/// \brief An optional database schema to filter on.
@@ -83,7 +83,7 @@ struct GetDbSchemas {
};

/// \brief A request to list database tables.
-struct GetTables {
+struct ARROW_FLIGHT_EXPORT GetTables {
/// \brief An optional database catalog to filter on.
util::optional<std::string> catalog;
/// \brief An optional database schema to filter on.
@@ -97,33 +97,33 @@ struct GetTables {
};

/// \brief A request to get SQL data type information.
-struct GetXdbcTypeInfo {
+struct ARROW_FLIGHT_EXPORT GetXdbcTypeInfo {
/// \brief A specific SQL type ID to fetch information about.
util::optional<int> data_type;
};

/// \brief A request to list primary keys of a table.
-struct GetPrimaryKeys {
+struct ARROW_FLIGHT_EXPORT GetPrimaryKeys {
/// \brief The given table.
TableRef table_ref;
};

/// \brief A request to list foreign key columns referencing primary key
/// columns of a table.
-struct GetExportedKeys {
+struct ARROW_FLIGHT_EXPORT GetExportedKeys {
/// \brief The given table.
TableRef table_ref;
};

/// \brief A request to list foreign keys of a table.
-struct GetImportedKeys {
+struct ARROW_FLIGHT_EXPORT GetImportedKeys {
/// \brief The given table.
TableRef table_ref;
};

/// \brief A request to list foreign key columns of a table that
/// reference columns in a given parent table.
-struct GetCrossReference {
+struct ARROW_FLIGHT_EXPORT GetCrossReference {
/// \brief The parent table (the one containing referenced columns).
TableRef pk_table_ref;
/// \brief The foreign table (for which foreign key columns will be listed).
@@ -131,19 +131,19 @@ struct GetCrossReference {
};

/// \brief A request to create a new prepared statement.
-struct ActionCreatePreparedStatementRequest {
+struct ARROW_FLIGHT_EXPORT ActionCreatePreparedStatementRequest {
/// \brief The SQL query.
std::string query;
};

/// \brief A request to close a prepared statement.
-struct ActionClosePreparedStatementRequest {
+struct ARROW_FLIGHT_EXPORT ActionClosePreparedStatementRequest {
/// \brief The server-generated opaque identifier for the statement.
std::string prepared_statement_handle;
};

/// \brief The result of creating a new prepared statement.
-struct ActionCreatePreparedStatementResult {
+struct ARROW_FLIGHT_EXPORT ActionCreatePreparedStatementResult {
/// \brief The schema of the query results, if applicable.
std::shared_ptr<Schema> dataset_schema;
/// \brief The schema of the query parameters, if applicable.
@@ -160,6 +160,7 @@ struct ActionCreatePreparedStatementResult {
///
/// \param[in] statement_handle The statement handle that will originate the ticket.
/// \return The parsed ticket as an string.
+ARROW_FLIGHT_EXPORT
arrow::Result<std::string> CreateStatementQueryTicket(
const std::string& statement_handle);

@@ -167,7 +168,7 @@ arrow::Result<std::string> CreateStatementQueryTicket(
///
/// Applications should subclass this class and override the virtual
/// methods declared on this class.
-class ARROW_EXPORT FlightSqlServerBase : public FlightServerBase {
+class ARROW_FLIGHT_EXPORT FlightSqlServerBase : public FlightServerBase {
private:
SqlInfoResultMap sql_info_id_to_result_;

@@ -488,7 +489,7 @@ class ARROW_EXPORT FlightSqlServerBase : public FlightServerBase {
};

/// \brief Auxiliary class containing all Schemas used on Flight SQL.
-class ARROW_EXPORT SqlSchema {
+class ARROW_FLIGHT_EXPORT SqlSchema {
public:
/// \brief Get the Schema used on GetCatalogs response.
/// \return The default schema template.
diff --git a/cpp/src/arrow/flight/sql/sql_info_internal.h b/cpp/src/arrow/flight/sql/sql_info_internal.h
index b18789c25..89328e413 100644
--- a/cpp/src/arrow/flight/sql/sql_info_internal.h
+++ b/cpp/src/arrow/flight/sql/sql_info_internal.h
@@ -18,6 +18,7 @@
#pragma once

#include "arrow/flight/sql/types.h"
+#include "arrow/flight/visibility.h"

namespace arrow {
namespace flight {
@@ -26,7 +27,7 @@ namespace internal {

/// \brief Auxiliary class used to populate GetSqlInfo's DenseUnionArray with different
/// data types.
-class SqlInfoResultAppender {
+class ARROW_FLIGHT_EXPORT SqlInfoResultAppender {
public:
/// \brief Append a string to the DenseUnionBuilder.
/// \param[in] value Value to be appended.
diff --git a/cpp/src/arrow/flight/sql/types.h b/cpp/src/arrow/flight/sql/types.h
index ebfb2ef0e..7f81fea3c 100644
--- a/cpp/src/arrow/flight/sql/types.h
+++ b/cpp/src/arrow/flight/sql/types.h
@@ -22,6 +22,7 @@
#include <unordered_map>
#include <vector>

+#include "arrow/flight/visibility.h"
#include "arrow/type_fwd.h"
#include "arrow/util/optional.h"
#include "arrow/util/variant.h"
@@ -43,7 +44,7 @@ using SqlInfoResult =
using SqlInfoResultMap = std::unordered_map<int32_t, SqlInfoResult>;

/// \brief Options to be set in the SqlInfo.
-struct SqlInfoOptions {
+struct ARROW_FLIGHT_EXPORT SqlInfoOptions {
/// \brief Predefined info values for GetSqlInfo.
enum SqlInfo {
/// \name Server Information
@@ -835,7 +836,7 @@ struct SqlInfoOptions {
};

/// \brief A SQL %table reference, optionally containing table's catalog and db_schema.
-struct TableRef {
+struct ARROW_FLIGHT_EXPORT TableRef {
/// \brief The table's catalog.
util::optional<std::string> catalog;
/// \brief The table's database schema.
--
2.30.0

2 changes: 2 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ package:
source:
url: https://dist.apache.org/repos/dist/release/arrow/arrow-{{ version }}/apache-arrow-{{ version }}.tar.gz
sha256: ad9a05705117c989c116bae9ac70492fe015050e1b80fb0e38fde4b5d863aaa3
patches:
- 0001-ARROW-16902-C-FlightRPC-Fix-DLL-linkage-in-Flight-SQ.patch # [win]

build:
number: 3
Expand Down

0 comments on commit f4244e7

Please sign in to comment.