joellubi commented on code in PR #1597:
URL: https://github.com/apache/arrow-adbc/pull/1597#discussion_r1517725122
##########
go/adbc/driver/flightsql/flightsql_connection.go:
##########
@@ -95,6 +97,136 @@ func doGet(ctx context.Context, cl *flightsql.Client,
endpoint *flight.FlightEnd
return nil, err
}
+func (c *cnxn) getSessionOptions(ctx context.Context) (map[string]interface{},
error) {
+ ctx = metadata.NewOutgoingContext(ctx, c.hdrs)
+ var header, trailer metadata.MD
+ rawOptions, err := c.cl.GetSessionOptions(ctx,
&flight.GetSessionOptionsRequest{}, grpc.Header(&header),
grpc.Trailer(&trailer), c.timeouts)
+ if err != nil {
+ // We're going to make a bit of a concession to backwards
compatibility
+ // here and ignore UNIMPLEMENTED or INVALID_ARGUMENT
+ grpcStatus := grpcstatus.Convert(err)
+ if grpcStatus.Code() == grpccodes.InvalidArgument ||
grpcStatus.Code() == grpccodes.Unimplemented {
+ return map[string]interface{}{}, nil
+ }
+ return nil, adbcFromFlightStatusWithDetails(err, header,
trailer, "GetSessionOptions")
+ }
+
+ options := make(map[string]interface{}, len(rawOptions.SessionOptions))
+ for k, rawValue := range rawOptions.SessionOptions {
+ switch v := rawValue.OptionValue.(type) {
+ case *flightproto.SessionOptionValue_BoolValue:
+ options[k] = v.BoolValue
+ case *flightproto.SessionOptionValue_DoubleValue:
+ options[k] = v.DoubleValue
+ case *flightproto.SessionOptionValue_Int64Value:
+ options[k] = v.Int64Value
+ case *flightproto.SessionOptionValue_StringValue:
+ options[k] = v.StringValue
+ case *flightproto.SessionOptionValue_StringListValue_:
+ if v.StringListValue.Values == nil {
+ options[k] = make([]string, 0)
+ } else {
+ options[k] = v.StringListValue.Values
+ }
+ case nil:
+ options[k] = nil
+ default:
+ return nil, adbc.Error{
+ Code: adbc.StatusNotImplemented,
+ Msg: fmt.Sprintf("[FlightSQL] Unknown session
option type %#v", rawValue),
+ }
+ }
+ }
+ return options, nil
+}
+
+type unsetSessionOption struct{}
+
+func (c *cnxn) setSessionOptions(ctx context.Context, key string, val
interface{}) error {
+ req := flight.SetSessionOptionsRequest{}
+
+ req.SessionOptions = make(map[string]*flight.SessionOptionValue)
Review Comment:
If you bump the arrow version in go.mod to a more recent commit, you should
be able to reuse `flight.NewSessionOptionValue()` or
`flight.NewSessionOptionValues()` to construct this.
--
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]