jduo commented on code in PR #34817:
URL: https://github.com/apache/arrow/pull/34817#discussion_r1370902463


##########
cpp/src/arrow/flight/sql/client.cc:
##########
@@ -793,6 +800,149 @@ ::arrow::Result<CancelResult> 
FlightSqlClient::CancelQuery(
   return Status::IOError("Server returned unknown result ", result.result());
 }
 
+::arrow::Result<std::map<std::string, SetSessionOptionResult>>
+FlightSqlClient::SetSessionOptions(
+    const FlightCallOptions& options,
+    const std::map<std::string, SessionOptionValue>& session_options) {
+  pb::ActionSetSessionOptionsRequest request;
+  auto* options_map = request.mutable_session_options();
+
+  for (const auto & [name, opt_value] : session_options) {
+    pb::SessionOptionValue pb_opt_value;
+
+    if (opt_value.index() == std::variant_npos)
+      return Status::Invalid("Undefined SessionOptionValue type ");
+
+    std::visit(overloaded{
+      // TODO move this somewhere common that can have Proto-involved code
+      [&](std::string v) { pb_opt_value.set_string_value(v); },
+      [&](bool v) { pb_opt_value.set_bool_value(v); },
+      [&](int32_t v) { pb_opt_value.set_int32_value(v); },
+      [&](int64_t v) { pb_opt_value.set_int64_value(v); },
+      [&](float v) { pb_opt_value.set_float_value(v); },
+      [&](double v) { pb_opt_value.set_double_value(v); },
+      [&](std::vector<std::string> v) {
+        auto* string_list_value = pb_opt_value.mutable_string_list_value();
+        for (const std::string& s : v)

Review Comment:
   Could use ->Add() or ->Assign() here to pass in a range instead of a loop. 
Note that the current code doesn't reserve() memory.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to