arina-ielchiieva commented on a change in pull request #1491: DRILL-6084: Show
Drill functions in WebUI for autocomplete
URL: https://github.com/apache/drill/pull/1491#discussion_r224742213
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
##########
@@ -495,4 +509,50 @@ private void generateOptionsDescriptionJSFile() throws
IOException {
writer.flush();
}
}
+
+ //Generates ACE library javascript populated with list of available SQL
functions
+ private void generateFunctionJS() throws IOException {
+ //Naturally ordered set of function names
+ TreeSet<String> functionSet = new TreeSet<>();
+ //Extracting ONLY builtIn functions (i.e those already available)
+ List<FunctionHolder> builtInFuncHolderList =
this.drillbit.getContext().getFunctionImplementationRegistry().getLocalFunctionRegistry()
+ .getAllJarsWithFunctionsHolders().get(LocalFunctionRegistry.BUILT_IN);
+
+ //Build List of usable functions
+ int skipCount = 0;
+ for (FunctionHolder builtInFunctionHolder : builtInFuncHolderList) {
+ String name = builtInFunctionHolder.getName();
+ if (!name.contains(" ") && name.matches("([a-z]|[A-Z])\\w+")) {
+ functionSet.add(name);
+ } else {
+ logger.debug("Non-alphabetic leading character. Function skipped : {}
", name);
+ skipCount++;
+ }
+ }
+ logger.debug("{} functions will not be available in WebUI : {} ",
skipCount);
+
+ //Generated file
+ File functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS);
+ //Template source Javascript file
+ InputStream aceModeSqlTemplateStream =
Resource.newClassPathResource(ACE_MODE_SQL_TEMPLATE_JS).getInputStream();
+ functionsListFile.deleteOnExit();
Review comment:
It's better to put `functionsListFile.deleteOnExit(); right after `File
functionsListFile = new File(getTmpJavaScriptDir(), ACE_MODE_SQL_JS);` file
creation for easier tracking.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services