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
Support passing a connection URL to Trino CLI #12587
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the reviewers, I understand this is pretty big and I'll try to split it up into multiple smaller commits.
6890ddd
to
2110ae1
Compare
.map(CommandLine.Model.OptionSpec::longestName) | ||
.collect(Collectors.toList()); | ||
|
||
TrinoUri uri = clientOptions.getTrinoUri(providedOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has a nice side effect of always converting all CLI options into URLs that can be used as JDBC URLs. Would it be useful to log the resulting connection URL on a debug level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it won't expose the password I'm for it.
Done. If there's anything else I can do to make this easier to review please let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs only need minor changes. From the behaviour side of things I am not sure we want the new behavior to be the default and hence the one we use in the documentation.
And importantly I would like confirmation that the old behavior will continue to work... and we will continue to ensure that with test coverage.
Let's wait for others to chime in about this. I made it the default since it's shorter. Users won't have to think about the option name (was it
Yes, no existing behavior should change and there are lots of tests for that. I added a few test cases with URLs. |
Useful feature for debugging @nineinchnick, looking forward to this! |
My concern is that it is NOT easier to type for any real use case beyond the URL only. In fact you need to know how to format the JDBC URL string. My other questions would be .. how much does this work if you combine JDBC string and other parameters. Are all parameters from both input methods combined somehow? What if there are collisions .. does on override the other? Which one wins out? We need to make sure we understand that and also document it. |
I meant it's easier only in the most basic use case,
You can combine options, start with the URL only and add more options instead of URL parameters. You can't specify the same parameter both in the URL and as a CLI option. There's one sentence clarifying this in the docs update. |
e292651
to
bb0fbd0
Compare
@electrum PTAL |
client/trino-jdbc/src/main/java/io/trino/jdbc/PropertyName.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractConnectionProperty.java
Outdated
Show resolved
Hide resolved
client/trino-client/src/main/java/io/trino/client/ClientSession.java
Outdated
Show resolved
Hide resolved
client/trino-client/src/main/java/io/trino/client/uri/TrinoUri.java
Outdated
Show resolved
Hide resolved
client/trino-client/src/main/java/io/trino/client/uri/TrinoUri.java
Outdated
Show resolved
Hide resolved
ff31cda
to
158310b
Compare
Rebased to include the new |
client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractConnectionProperty.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/AbstractConnectionProperty.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/ConnectionProperties.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDriverUri.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriver.java
Outdated
Show resolved
Hide resolved
sslUseSystemTrustStore.orElse(false)); | ||
} | ||
|
||
public void setupClient(OkHttpClient.Builder builder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in both of the usages we are passing new, fresh OkHttpClient.Builder here.
Can we instead do: public OkHttpClient.Builder toHttpClientBuilder()
?
this.sslSetup = OkHttpUtil::setupInsecureSsl; | ||
OkHttpClient.Builder builder = new OkHttpClient.Builder(); | ||
try { | ||
sslSetup = uri.getSetupSsl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this sslSetup at all?
Isn't uri.setupClient(builder);
already doing required SSL initialization?
9bbadd6
to
78f2845
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a whole bunch of minor wording improvements .. essentially though this is good to go. BIG change!
client/trino-client/src/main/java/io/trino/client/uri/TrinoUri.java
Outdated
Show resolved
Hide resolved
client/trino-client/src/main/java/io/trino/client/uri/TrinoUri.java
Outdated
Show resolved
Hide resolved
client/trino-client/src/main/java/io/trino/client/uri/TrinoUri.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverUri.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverUri.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoDriverUri.java
Outdated
Show resolved
Hide resolved
testing/trino-product-tests/src/main/java/io/trino/tests/product/cli/TestTrinoLdapCli.java
Outdated
Show resolved
Hide resolved
testing/trino-product-tests/src/main/java/io/trino/tests/product/cli/TestTrinoLdapCli.java
Outdated
Show resolved
Hide resolved
There is related failure in suite-ldap @nineinchnick:
|
@nineinchnick can you update release notes:
|
@@ -46,7 +46,7 @@ databases: | |||
jdbc_driver_class: ${databases.presto.jdbc_driver_class} | |||
jdbc_url: jdbc:trino://${databases.presto.host}:${databases.presto.port}/hive/tpcds | |||
jdbc_user: hive | |||
jdbc_password: "***empty***" | |||
jdbc_password: "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good now. Lets ship this!
All tests have passed. I have a small refactor around creating http client used by the jdbc and client but I’ll follow up in a separate PR. Merging this as-is for now. Thanks @nineinchnick for improving CLI and making it consistent with JDBC driver. |
BTW there's one last improvement to be done in JDBC error messages, when the value is being converted, for example from a string to a boolean, the error now looks like:
But we could say how the expected values look like, for example:
I'll follow up with another small PR. |
Description
Allow the Trino CLI to accept an URL parameter instead of a (sometimes long) list of options. URLs are parsed same as JDBC URLs, but they don't have the
jdbc:
prefix. If any parameters are set in the URL, they can't be also set as options. But they can be present in the config file because these are only treated as default values and can be overridden.Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
(x) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
(x) Release notes entries required with the following suggested text: