|
18 | 18 | #ifndef ARROW_FLIGHT_SQL_CLIENT_H |
19 | 19 | #define ARROW_FLIGHT_SQL_CLIENT_H |
20 | 20 |
|
| 21 | +#include <arrow/flight/client.h> |
| 22 | +#include <arrow/flight/types.h> |
| 23 | +#include <arrow/status.h> |
| 24 | +#include <google/protobuf/message.h> |
21 | 25 |
|
22 | | -class client { |
| 26 | +namespace arrow { |
| 27 | +namespace flight { |
| 28 | +namespace sql { |
| 29 | +namespace internal { |
| 30 | + |
| 31 | +/// \brief Flight client with Flight SQL semantics. |
| 32 | +template <class T = arrow::flight::FlightClient> |
| 33 | +class FlightSqlClientT { |
| 34 | + public: |
| 35 | + explicit FlightSqlClientT(T* client); |
| 36 | + |
| 37 | + ~FlightSqlClientT(); |
| 38 | + |
| 39 | + /// \brief Execute a query on the server. |
| 40 | + /// \param[in] options RPC-layer hints for this call. |
| 41 | + /// \param[out] flight_info The FlightInfo describing where to access the dataset |
| 42 | + /// \param[in] query The query to be executed in the UTF-8 format. |
| 43 | + /// \return Status. |
| 44 | + Status Execute(const FlightCallOptions& options, |
| 45 | + std::unique_ptr<FlightInfo>* flight_info, |
| 46 | + const std::string& query); |
| 47 | + |
| 48 | + /// \brief Execute an update query on the server. |
| 49 | + /// \param[in] options RPC-layer hints for this call. |
| 50 | + /// \param[out] rows The quantity of rows affected by the operation. |
| 51 | + /// \param[in] query The query to be executed in the UTF-8 format. |
| 52 | + /// \return Status. |
| 53 | + Status ExecuteUpdate(const FlightCallOptions& options, |
| 54 | + int64_t* rows, |
| 55 | + const std::string& query); |
| 56 | + |
| 57 | + /// \brief Request a list of catalogs. |
| 58 | + /// \param[in] options RPC-layer hints for this call. |
| 59 | + /// \param[out] flight_info The FlightInfo describing where to access the dataset. |
| 60 | + /// \return Status. |
| 61 | + Status GetCatalogs(const FlightCallOptions& options, |
| 62 | + std::unique_ptr<FlightInfo>* flight_info); |
| 63 | + |
| 64 | + /// \brief Request a list of schemas. |
| 65 | + /// \param[in] options RPC-layer hints for this call. |
| 66 | + /// \param[out] flight_info The FlightInfo describing where to access the |
| 67 | + /// dataset. |
| 68 | + /// \param[in] catalog The catalog. |
| 69 | + /// \param[in] schema_filter_pattern The schema filter pattern. |
| 70 | + /// \return Status. |
| 71 | + Status GetSchemas(const FlightCallOptions& options, |
| 72 | + std::unique_ptr<FlightInfo>* flight_info, |
| 73 | + std::string* catalog, |
| 74 | + std::string* schema_filter_pattern); |
| 75 | + |
| 76 | + /// \brief Given a flight ticket and schema, request to be sent the |
| 77 | + /// stream. Returns record batch stream reader |
| 78 | + /// \param[in] options Per-RPC options |
| 79 | + /// \param[in] ticket The flight ticket to use |
| 80 | + /// \param[out] stream the returned RecordBatchReader |
| 81 | + /// \return Status |
| 82 | + Status DoGet(const FlightCallOptions& options, |
| 83 | + const Ticket& ticket, |
| 84 | + std::unique_ptr<FlightStreamReader>* stream); |
| 85 | + |
| 86 | + /// \brief Request a list of tables. |
| 87 | + /// \param[in] options RPC-layer hints for this call. |
| 88 | + /// \param[out] flight_info The FlightInfo describing where to access the |
| 89 | + /// dataset. |
| 90 | + /// \param[in] catalog The catalog. |
| 91 | + /// \param[in] schema_filter_pattern The schema filter pattern. |
| 92 | + /// \param[in] table_filter_pattern The table filter pattern. |
| 93 | + /// \param[in] include_schema True to include the schema upon return, |
| 94 | + /// false to not include the schema. |
| 95 | + /// \param[in] table_types The table types to include. |
| 96 | + /// \return Status. |
| 97 | + Status GetTables(const FlightCallOptions& options, |
| 98 | + std::unique_ptr<FlightInfo>* flight_info, |
| 99 | + const std::string* catalog, |
| 100 | + const std::string* schema_filter_pattern, |
| 101 | + const std::string* table_filter_pattern, |
| 102 | + bool include_schema, |
| 103 | + std::vector<std::string>& table_types); |
| 104 | + |
| 105 | + /// \brief Request the primary keys for a table. |
| 106 | + /// \param[in] options RPC-layer hints for this call. |
| 107 | + /// \param[out] flight_info The FlightInfo describing where to access the dataset. |
| 108 | + /// \param[in] catalog The catalog. |
| 109 | + /// \param[in] schema The schema. |
| 110 | + /// \param[in] table The table. |
| 111 | + /// \return Status. |
| 112 | + Status GetPrimaryKeys(const FlightCallOptions& options, |
| 113 | + std::unique_ptr<FlightInfo>* flight_info, |
| 114 | + const std::string* catalog, |
| 115 | + const std::string* schema, |
| 116 | + const std::string& table); |
| 117 | + |
| 118 | + /// \brief Retrieves a description about the foreign key columns that reference the |
| 119 | + /// primary key columns of the given table. |
| 120 | + /// \param[in] options RPC-layer hints for this call. |
| 121 | + /// \param[out] flight_info The FlightInfo describing where to access the dataset. |
| 122 | + /// \param[in] catalog The foreign key table catalog. |
| 123 | + /// \param[in] schema The foreign key table schema. |
| 124 | + /// \param[in] table The foreign key table. Cannot be null. |
| 125 | + /// \return Status. |
| 126 | + Status GetExportedKeys(const FlightCallOptions& options, |
| 127 | + std::unique_ptr<FlightInfo>* flight_info, |
| 128 | + const std::string* catalog, |
| 129 | + const std::string* schema, |
| 130 | + const std::string& table); |
| 131 | + |
| 132 | + /// \brief Retrieves the foreign key columns for the given table. |
| 133 | + /// \param[in] options RPC-layer hints for this call. |
| 134 | + /// \param[out] flight_info The FlightInfo describing where to access the dataset. |
| 135 | + /// \param[in] catalog The primary key table catalog. |
| 136 | + /// \param[in] schema The primary key table schema. |
| 137 | + /// \param[in] table The primary key table. Cannot be null. |
| 138 | + /// \return Status. |
| 139 | + Status GetImportedKeys(const FlightCallOptions& options, |
| 140 | + std::unique_ptr<FlightInfo>* flight_info, |
| 141 | + const std::string* catalog, |
| 142 | + const std::string* schema, |
| 143 | + const std::string& table); |
| 144 | + |
| 145 | + /// \brief Request a list of table types. |
| 146 | + /// \param[in] options RPC-layer hints for this call. |
| 147 | + /// \param[out] flight_info The FlightInfo describing where to access the dataset. |
| 148 | + /// \return Status. |
| 149 | + Status GetTableTypes(const FlightCallOptions& options, |
| 150 | + std::unique_ptr<FlightInfo>* flight_info); |
| 151 | + |
| 152 | + |
| 153 | + private: |
| 154 | + T* client; |
23 | 155 | }; |
24 | 156 |
|
| 157 | +} // namespace internal |
| 158 | + |
| 159 | +typedef internal::FlightSqlClientT<FlightClient> FlightSqlClient; |
| 160 | + |
| 161 | +} // namespace sql |
| 162 | +} // namespace flight |
| 163 | +} // namespace arrow |
| 164 | + |
| 165 | +#endif // ARROW_FLIGHT_SQL_CLIENT_H |
25 | 166 |
|
26 | | -#endif //ARROW_FLIGHT_SQL_CLIENT_H |
| 167 | +#include <arrow/flight/flight-sql/client_impl.h> |
0 commit comments