Skip to content

Flight session management - #1

Draft
indigophox wants to merge 51 commits into
masterfrom
flight-session-management
Draft

indigophox wants to merge 51 commits into
masterfrom
flight-session-management

Conversation

@indigophox

Copy link
Copy Markdown
Owner

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

jduo and others added 30 commits January 20, 2023 17:45
Add methods to easily get the path and query parameters from
a Location that has been parsed from a URI.

Add a method to return this data as headers that can be
supplied to FlightCallOptions
/// \param[in] session_options The session options to set.
::arrow::Result<std::vector<SetSessionOptionResult>> SetSessionOptions(
const FlightCallOptions& options,
const std::vector<SessionOption>& session_options);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the client modify the SessionOptions and update them here or is this use once and error if they try to set them again? I guess they could call GetSessionOptions and pass that back in here.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally we were not going to but given we're necessarily going to be setting the desired Resource-Path session option value /after/ connecting I don't see that it's going to be immutable in any way. If we start thinking in terms of it being updated we do need to ensure that it's captured at call time by the FlightProducer and can't change from that call handing code's perspective so that there isn't a race if e.g. SetSessionOptions is called again while a query is busy executing or whatnot (i.e. snapshot the session state for the FlightProducer's handler's perspective or read/copy the values at handler init or whatever).

/// \brief Gets current session options.
///
/// \param[in] options RPC-layer hints for this call.
::arrow::Result<std::vector<SessionOption>> GetSessionOptions(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the user could call GetSessionOptions then pass the std::vector back into SetSessionOptions. I assume this would get rejected?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably work (server implementation-defined) and should effectively be a no-op unless one of the option names is defined by the server to be set-once-and-don't-allow-changing in which case it might complain.

///
/// \param[in] options RPC-layer hints for this call.
/// \param[in] session_options The session options to set.
::arrow::Result<std::vector<SetSessionOptionResult>> SetSessionOptions(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a may to set SessionOptionResult in a GetFlightInfo call as the likes of Power BI won't handle two calls from a driver easily.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetSessionOptions will be part of the ODBC driver connection init, after which cookies (presumably persisted by the ODBC driver which it might need to be updated to support, or by the ODBC-using application which I don't think is the case(?!)) will persist the session state reference.

Comment thread cpp/src/arrow/flight/sql/client.cc Outdated
break;
case flight_sql_pb::SessionOption::kStringListValue:
std::vector<std::string> vlist;
if (in_opt.string_list_value().values_size() > 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this if statement here for performance? It looks like it can be removed which would clean up/make this more readable

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, performance. It's consistent with a lot of other Arrow code but it's likely that calling std::vector.reserve(0) doesn't cost much at all, particularly as the allocator isn't touched. Can remove it if you think that's cleaner.

return CloseSessionResult::kClosing;
case flight_sql_pb::ActionCloseSessionResult::CLOSE_RESULT_NOT_CLOSEABLE:
return CloseSessionResult::kNotClosable;
default:

@dylang-bq dylang-bq Mar 30, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this switch statement have a default case when the other switch statements don't have one? Especially since the default case doesn't do anything here.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's for a Protobuf enum that has sentinel values that the build chain barfs on. No other reason :)

Comment thread cpp/src/arrow/flight/sql/server.cc Outdated
break;
case pb::sql::SessionOption::kStringListValue:
std::vector<std::string> vlist;
if (in_opt.string_list_value().values_size() > 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here with this if statement. Why is it needed? To me the code would look cleaner without it

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty fair, while it's consistent with other usage it's probably a noop to call a .reserve() that doesn't change the vector's allocated size so it's a moot "optimization" for the most part.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its consistent with other usage that's fine with me. I would rather see consistency within a code base

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it and I don't think it's problematic inconsistency, and shouldn't save any meaningful execution time so going to leave it cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants