Skip to content

SQL: Refactor Tableau connector to make use of the connection properties #69169

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

Merged
merged 8 commits into from
Mar 15, 2021

Conversation

bpintea
Copy link
Contributor

@bpintea bpintea commented Feb 18, 2021

This refactors the way the connection URL is being built, to make use of
frameworks' ability to construct the URL based on a set of connection
properties.
This comes with the benefit that the URI attributes escaping is taken
care for us.

The PR also removes the URI "manual" logging, which is already done
by the framework, with proper masking of the password.

This refactors the way the connection URL is being built, to make use of
frameworks' ability to construct the URL based on a set of connection
propreties.
This also ensures that the URI attributes are properly escaped.
@bpintea bpintea requested a review from astefan February 18, 2021 09:31
@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Feb 18, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@bpintea
Copy link
Contributor Author

bpintea commented Feb 18, 2021

@elasticmachine update branch

@bpintea
Copy link
Contributor Author

bpintea commented Feb 18, 2021

@elasticmachine run elasticsearch-ci/bwc

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM. I've left two comments, though

for (var i = 0; i < avps.length; i++) {
var tokens = avps[i].split("=");
if (tokens.length != 2 || tokens[0].length == 0 || tokens[1].length == 0) {
logging.log("Malformed AVP: [" + avps[i] + "] in additional params: [" + extraProps + "]");
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess what AVP means, but I am not sure. Especially this being a logged message, I'd give it a meaningful name. Something like "Malformed attribute-value pair:......"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Acronym expanded.

@@ -6,35 +6,7 @@
} else{
urlBuilder += "http://";
}
urlBuilder += attr["server"] + ":" + attr["port"];
urlBuilder += attr["server"] + ":" + attr["port"] + "?";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the question mark at the end always necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes: the "user" is a mandatory config option (can't submit the form if not filled), so there will always be a property set; so adding the ? is safe.

@bpintea
Copy link
Contributor Author

bpintea commented Feb 19, 2021

@elasticmachine update branch

elasticmachine and others added 2 commits February 19, 2021 05:58
Remove logging to prevent sensitive info being logged, inline with
Tableau's best practices recommendations.
@bpintea
Copy link
Contributor Author

bpintea commented Mar 15, 2021

@elasticmachine run elasticsearch-ci/bwc

if (extraProps != null && extraProps.trim().length > 0) {
var avps = extraProps.trim().split(/[\s&]/);
for (var i = 0; i < avps.length; i++) {
var tokens = avps[i].split("=");
Copy link
Contributor

@matriv matriv Mar 15, 2021

Choose a reason for hiding this comment

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

Question, to be more lenient shouldn't we trim the split tokens, to treat something like:
" param1 = value1 "
(used double quotes to denote surrounding spaces)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Space is accepted as a delimiter between the AVPs, as a friendlier alternative to &; i.e. both forms a=b&c=d and a=b c=d are permitted. Spaces would normally need to be encoded in a URI.
That's why the initial AVP splitting is done by .split(/[\s&]/).
I've added a comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thx for explaining!

@bpintea
Copy link
Contributor Author

bpintea commented Mar 15, 2021

@elasticmachine update branch

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

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

LGTM

@bpintea bpintea merged commit 3c1e0a9 into elastic:master Mar 15, 2021
@bpintea bpintea deleted the enh/tableau_conn_props branch March 15, 2021 15:49
bpintea added a commit that referenced this pull request Mar 15, 2021
…ies (#69169)

* Refactor to make use of the connection propreties

This refactors the way the connection URL is being built, to make use of
frameworks' ability to construct the URL based on a set of connection
propreties.
This also ensures that the URI attributes are properly escaped.

(cherry picked from commit 3c1e0a9)
bpintea added a commit that referenced this pull request May 18, 2021
…ies (#69169)

* Refactor to make use of the connection propreties

This refactors the way the connection URL is being built, to make use of
frameworks' ability to construct the URL based on a set of connection
propreties.
This also ensures that the URI attributes are properly escaped.

(cherry picked from commit 3c1e0a9)
bpintea added a commit that referenced this pull request May 18, 2021
…ies (#69169)

* Refactor to make use of the connection propreties

This refactors the way the connection URL is being built, to make use of
frameworks' ability to construct the URL based on a set of connection
propreties.
This also ensures that the URI attributes are properly escaped.

(cherry picked from commit 3c1e0a9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants