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

feat: simple flight sql CLI client #3789

Merged

Conversation

crepererum
Copy link
Contributor

@crepererum crepererum commented Mar 2, 2023

Which issue does this PR close?

-

Rationale for this change

It's a bit of a pity that the Rust ecosystem has a flight SQL client, async runtimes, logging, and a nice CLI parser but we don't have an easy-to-use oneshot flight SQL client and require people to write code or use Java executables just to try out Flight SQL. Here is a simple CLI client that wires up everything end2end. It currently only perform as simple "execute query" but people may want to extend it in the future.

What changes are included in this PR?

I simple CLI client.

Are there any user-facing changes?

New optional binary.

Small demo (using InfluxDB cloud):

Screenshot from 2023-03-02 14-11-29

@github-actions github-actions bot added arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate labels Mar 2, 2023
@crepererum crepererum force-pushed the crepererum/flight_sql_cli_client branch 2 times, most recently from 0fa0d66 to 10cdfb0 Compare March 6, 2023 10:39
@crepererum crepererum marked this pull request as ready for review March 6, 2023 10:40
@crepererum crepererum force-pushed the crepererum/flight_sql_cli_client branch 2 times, most recently from 934aa51 to 75403f0 Compare March 6, 2023 12:56
Copy link
Contributor

@tustvold tustvold 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, just some minor questions about the protocol really

arrow-flight/src/bin/flight_sql_client.rs Outdated Show resolved Hide resolved
(None, None) => {}
(Some(username), Some(password)) => {
client
.handshake(&username, &password)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this if nothing is done with the response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the user does not provide the token, the handshake message may contain it (see impl. of the handshake method). So the username+password is exchanged for a token which is then used in subsequent requests. The token is a state of the client object. I think for many applications that will work just fine (it doesn't for InfluxDB cloud at the moment, there you pass the token manually into the CLI; just to be transparent).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I didn't realise that handshake modified the client with the received token. Makes sense, somewhat questionable API but 👍

@@ -41,6 +41,12 @@ prost-derive = { version = "0.11", default-features = false }
tokio = { version = "1.0", default-features = false, features = ["macros", "rt", "rt-multi-thread"] }
futures = { version = "0.3", default-features = false, features = ["alloc"] }

# CLI-related dependencies
arrow = { version = "34.0.0", path = "../arrow", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

This is kind of unfortunate, even as an optional dependency... Perhaps we should move the pretty printing into arrow-cast 🤔

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'm open 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'll see what I can do as a follow up

@crepererum crepererum force-pushed the crepererum/flight_sql_cli_client branch from 75403f0 to 37ff6c5 Compare March 6, 2023 15:50
@tustvold tustvold merged commit 7f460af into apache:master Mar 6, 2023
@ursabot
Copy link

ursabot commented Mar 6, 2023

Benchmark runs are scheduled for baseline = 2f54ae9 and contender = 7f460af. 7f460af 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 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.

3 participants