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

Pass pull Request<FlightDescriptor> to FlightSqlService impls #2309

Merged
merged 4 commits into from
Aug 5, 2022

Conversation

avantgardnerio
Copy link
Contributor

@avantgardnerio avantgardnerio commented Aug 3, 2022

Which issue does this PR close?

Closes #2308.

Rationale for this change

Make it so Ballista can run non-trivial FlightSql queries.

What changes are included in this PR?

Not-ready-for merge code that I was successfully able to use to:

  1. register the TPC-H customer table
  2. select top 1 c_name from customer order by c_name (in my own custom JDBC driver)
  3. get a result

Are there any user-facing changes?

FlightSql queries become useful and JDBC works.

@github-actions github-actions bot added arrow-flight Changes to the arrow-flight crate parquet Changes to the parquet crate parquet-derive labels Aug 3, 2022
@avantgardnerio
Copy link
Contributor Author

CC @andygrove and @alamb

) -> Result<Response<FlightInfo>, Status>;

/// Get a FlightInfo for executing an already created prepared statement.
async fn get_flight_info_prepared_statement(
&self,
query: CommandPreparedStatementQuery,
request: FlightDescriptor,
auth: &Option<String>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this to all the methods is the API change.

@avantgardnerio avantgardnerio changed the title Able to get session context, but JDBC driver hung Pass bearer token to FlightSqlService impls Aug 3, 2022
@alamb
Copy link
Contributor

alamb commented Aug 3, 2022

cc @wangfenjin who contributed the initial FlightSQL work

@alamb
Copy link
Contributor

alamb commented Aug 3, 2022

Also, for other reviewers, a whitespace blind diff makes this PR much smaller: https://github.com/apache/arrow-rs/pull/2309/files?w=1 and palatable for review 😅

arrow-flight/src/sql/server.rs Outdated Show resolved Hide resolved
arrow-flight/src/sql/server.rs Show resolved Hide resolved
@alamb
Copy link
Contributor

alamb commented Aug 3, 2022

Also cc @timvw

@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2022

Codecov Report

Merging #2309 (d63e660) into master (e835853) will decrease coverage by 0.64%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2309      +/-   ##
==========================================
- Coverage   81.26%   80.61%   -0.65%     
==========================================
  Files         248      248              
  Lines       60605    59905     -700     
==========================================
- Hits        49249    48295     -954     
- Misses      11356    11610     +254     
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/array/ffi.rs 0.00% <0.00%> (-100.00%) ⬇️
arrow/src/ffi.rs 0.00% <0.00%> (-87.53%) ⬇️
arrow/src/ffi_stream.rs 0.00% <0.00%> (-79.90%) ⬇️
arrow/src/datatypes/ffi.rs 0.00% <0.00%> (-76.66%) ⬇️
arrow/src/array/array_list.rs 94.27% <0.00%> (-1.57%) ⬇️
...row/src/array/builder/string_dictionary_builder.rs 90.64% <0.00%> (-0.72%) ⬇️
arrow/src/array/data.rs 84.33% <0.00%> (-0.71%) ⬇️
arrow/src/ipc/writer.rs 84.92% <0.00%> (-0.54%) ⬇️
... and 9 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@wangfenjin
Copy link
Contributor

We need to check the implementation in c or other languages, seems they use something like middleware to do this, we need to make sure rust implementation same with others.

Pass meta to every handler function this way might not be a good idea.

@wangfenjin
Copy link
Contributor

Sorry I didn't pay attention to the auth part in the initial implementation...

@@ -66,76 +67,87 @@ pub trait FlightSqlService:
&self,
query: CommandStatementQuery,
request: FlightDescriptor,
metadata: MetadataMap,
Copy link
Contributor

@tustvold tustvold Aug 4, 2022

Choose a reason for hiding this comment

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

I wonder if it might be better to modify request to be Request<FlightDescriptor>. Not only would this provide access to the metadata map, but also things like extensions. I think it would also avoid a clone

In particular extensions are a common way to allow middleware to extract data from the headers, and make it easily accessible to downstreams. As an example in IOx, we use a middleware to extract tracing information from requests - https://github.com/influxdata/influxdb_iox/blob/main/trace_http/src/tower.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@avantgardnerio
Copy link
Contributor Author

something like middleware to do this

I could see the handshake method could maybe be turned into a middleware-style handler, but since it's part of the flight protocol spec it makes sense to me to proxy it up like the other methods. Do you have links handy for the other implementations?

Pass meta to every handler function

The only other way I can think of doing it is with something like a ThreadLocal context, but a quick googling isn't providing me with an equivalent for co-routine context in Rust/Tokio.

Sorry I didn't pay attention

No worries, thanks for getting it started! I'd have been lost without the foundation you laid :)

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.

I think the interface is looking quite nice now 👌 Very straightforward.

Thanks @tustvold @avantgardnerio and @wangfenjin for the discussion

@alamb
Copy link
Contributor

alamb commented Aug 4, 2022

Looks like there are a few more CI checks to clean up but I think this PR is quite close

@alamb alamb changed the title Pass bearer token to FlightSqlService impls Pass pull Request<FlightDescriptor> to FlightSqlService impls Aug 4, 2022
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.

I think this looks like a great improvement. Thank you @avantgardnerio

@alamb
Copy link
Contributor

alamb commented Aug 4, 2022

I'll plan to merge this tomorrow before making an arrow 20.0.0 release candidate unless someone objects or would like more time to review

@tustvold tustvold merged commit 0af81e8 into apache:master Aug 5, 2022
@ursabot
Copy link

ursabot commented Aug 5, 2022

Benchmark runs are scheduled for baseline = 2683b06 and contender = 0af81e8. 0af81e8 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

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 parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update FlightSqlService trait to pass session info along
6 participants