Skip to content

Conversation

alison985
Copy link
Contributor

Addresses mozilla#454 which fixes mozilla#232

@vercel
Copy link

vercel bot commented Aug 12, 2018

This pull request is automatically deployed with Now.

To access deployments, click Details below or on the icon next to each push.

Copy link
Contributor

@jezdez jezdez left a comment

Choose a reason for hiding this comment

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

Hm, I'm not sure I understand how this speeds things up, could you explain the things this patch does please?

getCompletions(state, session, pos, prefix, callback) {
if (prefix.length === 0 || !$scope.schema) {
// make a variable for the auto completion in the query editor
$scope.autoCompleteSchema = $scope.schema; // removeExtraSchemaInfo(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate what this does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It essentially separates the interface schema (schema) and the auto complete schema (autoCompleteSchema) to handle UI differences between them.

Copy link
Contributor

Choose a reason for hiding this comment

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

To be able to modify the colums further down below?

If we remove the [P] code since #2764 isn't going to merged adding it, then what leaves this PR us with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given all of this, I'd be okay with closing this PR and closing the issue to port this change upstream. What do you think @jezdez?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, let's revisit this if the follow-up for #2764 is merged.

parensStartAt = 1; // linter complains without this line
}
// remove '[P] ' for partition keys
if (c.charAt(0) === '[') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we have [P] in this code base yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, but that is a pending PR and because it's an if statement it doesn't hurt anything prior to that PR being merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I see, I'm afraid this will need to be removed for now since I got feedback from Arik about #2764 being problematic in terms of UI design. I will follow-up on this in the PR there and ask the Redash UX people to weigh in on a way forward. In the meantime we shouldn't hold back this PR here.


table.columns.forEach((c) => {
keywords[c] = 'Column';
table.columns.forEach((c) => { // autoCompleteColumns
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you leave a code comment what this does?

if (c.charAt(0) === '[') {
c = c.substring(4, c.length);
}
// keywords[c] = 'Column'; // dups columns
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the commented out line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is essentially my note to self that keywords[c] will duplicate columns in the list, that's why I had to make it keywords[${table.name}.${c}]. This will prevent me from trying to change it back later to reduce complexity and create a bug.

editor.setOption('enableBasicAutocompletion', false);
} else {
editor.setOption('enableLiveAutocompletion', true);
editor.setOption('enableBasicAutocompletion', true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jezdez to answer your question about how this makes the performance faster, the key to the performance improvement is in these 2 lines about enableBasicAutocompletion. The text editor redash uses is Ace Editor and without these lines there were autocompletion calls happening via the default configuration through Ace Editor that were causing a performance issue.

Yes, a lot of other things seem to have ended up in the commit that this PR is porting upstream.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking further into this, this seems to actually just add an additional command to the editor (https://github.com/ajaxorg/ace/blob/51a9b7c74671b86dceab01296a7d09e877853484/lib/ace/ext/language_tools.js#L175-L203) that triggers the auto-complete menu when typing ctrl+space (et al.). Since this is in addition to the live auto-completion (where "live" means that is happens on any input change of the editor), I don't see how this improves performance per-se. Instead this seems like a drive-by change that was shipped in the original code change in the Mozilla fork. Not a big deal, but just want to state that this is a thing.

let parensStartAt = c.indexOf('(') - 1;
c = c.substring(0, parensStartAt);
parensStartAt = 1; // linter complains without this line
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So this removes columns that end with a closing parenthesis at the point where the opening parenthesis is? Can you elaborate which data sources have those kind of colums?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jezdez It's not a data source thing, it's a Mozilla fork thing. In the Mozilla fork the field type is appended to the field name. So a field named id becomes id (integer) in the schema browser.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, let's remove this then.

@jezdez
Copy link
Contributor

jezdez commented Aug 28, 2018

@alison985 Before we merge this I think we need to further review what the changes done after mozilla#232 mean for this repo that doesn't have all the changes made in the fork.

@alison985
Copy link
Contributor Author

See comment #2746 (comment)

Jannis and I agreed to close this one. Some of the changes may be relevant in the future, but not until the related features are upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perf issues after m9 deployment

2 participants