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

Update FlightSqlService trait to proxy handshake #2211

Merged
merged 5 commits into from Jul 28, 2022

Conversation

avantgardnerio
Copy link
Contributor

@avantgardnerio avantgardnerio commented Jul 28, 2022

Which issue does this PR close?

Closes #2210.

Rationale for this change

Apache Arrow Ballista now supports FlightSQL, and can run simple statements like select 1;, however due to its architecture, tables need to be registered before any substantive queries can be run. Unfortunately, tables have to be registered on a context, or else the next query will have no idea that they were registered. The native Ballista protocol uses a custom field to implement this behavior, but for FlightSQL, we should use its native method. However the existing FlightSqlService trait forces this to return an unimplemented Err.

What changes are included in this PR?

Proxying of the handshake() method

Are there any user-facing changes?

Other implementers of FlightSqlService will have to implement the method (they can just return NotImplemented as that was the previous behavior).

@github-actions github-actions bot added the arrow-flight Changes to the arrow-flight crate label Jul 28, 2022
@avantgardnerio
Copy link
Contributor Author

Tagging @alamb and @viirya just in case you don't see.

Comment on lines 52 to 58
async fn do_handshake(
&self,
request: Request<Streaming<HandshakeRequest>>,
) -> Result<
Response<Pin<Box<dyn Stream<Item = Result<HandshakeResponse, Status>> + Send>>>,
Status,
>;
Copy link
Member

Choose a reason for hiding this comment

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

Should we provide default implementation that returns "Not yet implemented" error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wow, I just threw the default implementation right on the trait and it compiled! I had no idea that would work nowadays 😄

Copy link
Member

Choose a reason for hiding this comment

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

Yea, as you see, you can "override" default implementation in a trait nowadays.

@codecov-commenter
Copy link

Codecov Report

Merging #2211 (32a6aed) into master (bc493d9) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2211      +/-   ##
==========================================
- Coverage   82.56%   82.53%   -0.04%     
==========================================
  Files         239      239              
  Lines       62269    62299      +30     
==========================================
+ Hits        51415    51418       +3     
- Misses      10854    10881      +27     
Impacted Files Coverage Δ
arrow-flight/examples/flight_sql_server.rs 0.00% <0.00%> (ø)
arrow-flight/src/sql/server.rs 0.00% <0.00%> (ø)
arrow/src/datatypes/datatype.rs 63.00% <0.00%> (+0.31%) ⬆️
...rquet/src/arrow/record_reader/definition_levels.rs 89.02% <0.00%> (+0.42%) ⬆️
...row/src/array/builder/string_dictionary_builder.rs 91.36% <0.00%> (+0.71%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.

Copy link
Member

@viirya viirya 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.

@@ -256,9 +270,10 @@ where

async fn handshake(
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this isn't cool that the impl doesn't call the underlying implementation

let output = futures::stream::iter(vec![result]);
return Ok(Response::new(Box::pin(output)));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good 👍

It would be awesome to get some test coverage of this code eventually 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like to follow acceptance test driven development when possible. Do you think the rust FlightSqlClient is far enough along to integration test with?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed that we eventually should add some test coverage for flight sql server. Currently we don't have any test coverage for it, not just this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have TPC-H up and running, I'll come back around to this and look at the main issues: cloning the server state & testing. Thanks for your feedback and helping get it merged!

Copy link
Contributor

Choose a reason for hiding this comment

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

I like to follow acceptance test driven development when possible. Do you think the rust FlightSqlClient is far enough along to integration test with?

I think there is also a place for targeted for regression tests (so that, for example, if someone breaks the code accidentally in some future refactoring, they also get a test failure). However, the right balance and where to draw the line between the two is always a matter of judgement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't mean to imply integration tests were the only way. I think they become exponentially impossible to maintain as code coverage increases - so unit tests are also required. I was just (and still am) hoping to start with a FlighSql-rs test then add unit tests in addition to that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we are in total agreement

@viirya viirya merged commit acd8042 into apache:master Jul 28, 2022
@ursabot
Copy link

ursabot commented Jul 28, 2022

Benchmark runs are scheduled for baseline = 48cc6c3 and contender = acd8042. acd8042 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@avantgardnerio avantgardnerio deleted the bg_auth branch July 29, 2022 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow-flight Changes to the arrow-flight crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FlightSqlService trait does not allow impls to do handshake
5 participants