Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add begin/end_transaction methods in FlightSqlServiceClient #6026

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

lewiszlw
Copy link
Member

@lewiszlw lewiszlw commented Jul 9, 2024

Which issue does this PR close?

Closes #.

Rationale for this change

FlightSqlService suppots transaction feature, so add some helper methods for client.

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate labels Jul 9, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks good to me -- thank you @lewiszlw

Could you please add basic integration tests for this code (that shows the data correctly making it from the client to the server)?

I think an example of such a test is here.

#[tokio::test]
async fn test_handshake() {
do_test(|test_server, mut client| async move {
client.add_header("foo-header", "bar-header-value").unwrap();
let request_payload = Bytes::from("foo-request-payload");
let response_payload = Bytes::from("bar-response-payload");
let request = HandshakeRequest {
payload: request_payload.clone(),
protocol_version: 0,
};
let response = HandshakeResponse {
payload: response_payload.clone(),
protocol_version: 0,
};
test_server.set_handshake_response(Ok(response));
let response = client.handshake(request_payload).await.unwrap();
assert_eq!(response, response_payload);
assert_eq!(test_server.take_handshake_request(), Some(request));
ensure_metadata(&client, &test_server);
})
.await;
}

Though that looks like it is only for FlightServiceClient rather than the FlightSqlServiceClient 🤔

@@ -399,6 +403,54 @@ impl FlightSqlServiceClient<Channel> {
))
}

/// Request to begin a transaction.
pub async fn begin_transaction(&mut self) -> Result<Bytes, ArrowError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if there were any parameters that should be passed to this function, but I see the underlying message doesn't have any either so this makes sense to me

@lewiszlw
Copy link
Member Author

I added a test in flight_sql_client_cli.rs. (maybe could move to a new file flight_sql_client.rs)

@alamb
Copy link
Contributor

alamb commented Jul 13, 2024

I added a test in flight_sql_client_cli.rs. (maybe could move to a new file flight_sql_client.rs)

Yeah, it seems like flight_sql_client_cli.rs is slowly becoming the test for the FlightSqlServiceClient -- I agree reaming it and starting to cover all the FlightSQL methods might be good

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @lewiszlw

@@ -318,244 +358,6 @@ impl FlightSqlService for FlightSqlServiceImpl {
Ok(resp)
}

async fn get_flight_info_substrait_plan(
Copy link
Contributor

Choose a reason for hiding this comment

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

this all have default impls, so it is ok to remove them, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

@alamb alamb merged commit 31b8ba0 into apache:master Jul 15, 2024
13 checks passed
@alamb
Copy link
Contributor

alamb commented Jul 15, 2024

Thanks again @lewiszlw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants