You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by cw...@apache.org on 2019/04/18 06:13:00 UTC
[incubator-druid] branch master updated: Capitalize keywords in SQL
auto complete (#7462)
This is an automated email from the ASF dual-hosted git repository.
cwylie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git
The following commit(s) were added to refs/heads/master by this push:
new 99ddce1 Capitalize keywords in SQL auto complete (#7462)
99ddce1 is described below
commit 99ddce1277b60db4c1fcdabc9e80d644ba3f16a1
Author: Qi Shu <sh...@gmail.com>
AuthorDate: Wed Apr 17 23:12:55 2019 -0700
Capitalize keywords in SQL auto complete (#7462)
* Split commit; keep auto complete only
* Add comment
---
web-console/src/components/sql-control.tsx | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/web-console/src/components/sql-control.tsx b/web-console/src/components/sql-control.tsx
index 1aa9089..832ea8d 100644
--- a/web-console/src/components/sql-control.tsx
+++ b/web-console/src/components/sql-control.tsx
@@ -83,6 +83,28 @@ export class SqlControl extends React.Component<SqlControlProps, SqlControlState
};
}
+ private replaceDefaultAutoCompleter = () => {
+ /*
+ Please refer to the source code @
+ https://github.com/ajaxorg/ace/blob/9b5b63d1dc7c1b81b58d30c87d14b5905d030ca5/lib/ace/ext/language_tools.js#L41
+ for the implementation of keyword completer
+ */
+ const keywordCompleter = {
+ getCompletions: (editor: any, session: any, pos: any, prefix: any, callback: any) => {
+ if (session.$mode.completer) {
+ return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
+ }
+ const state = editor.session.getState(pos.row);
+ let keywordCompletions = session.$mode.getCompletions(state, session, pos, prefix);
+ keywordCompletions = keywordCompletions.map((d: any) => {
+ return Object.assign(d, {name: d.name.toUpperCase(), value: d.value.toUpperCase()});
+ });
+ return callback(null, keywordCompletions);
+ }
+ };
+ langTools.setCompleters([langTools.snippetCompleter, langTools.textCompleter, keywordCompleter]);
+ }
+
private addDatasourceAutoCompleter = async (): Promise<any> => {
const datasourceResp = await axios.post('/druid/v2/sql', { query: `SELECT datasource FROM sys.segments GROUP BY 1`});
const datasourceList: any[] = datasourceResp.data.map((d: any) => {
@@ -169,6 +191,7 @@ export class SqlControl extends React.Component<SqlControlProps, SqlControlState
private addCompleters = async () => {
try {
+ this.replaceDefaultAutoCompleter();
this.addFunctionAutoCompleter();
await this.addDatasourceAutoCompleter();
await this.addColumnNameAutoCompleter();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org