zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [1/3] zeppelin git commit: [ZEPPELIN-2297] improvements to jdbc autocompleter
Date Mon, 17 Apr 2017 05:18:42 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master 775607f10 -> 4d398ef2a


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d398ef2/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
index 4321e22..c4ff6ab 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
@@ -121,7 +121,8 @@ public class MockInterpreterResourcePool extends Interpreter {
   }
 
   @Override
-  public List<InterpreterCompletion> completion(String buf, int cursor) {
+  public List<InterpreterCompletion> completion(String buf, int cursor,
+      InterpreterContext interpreterContext) {
     return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d398ef2/zeppelin-server/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
b/zeppelin-server/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
index b8343c0..1b1306a 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
@@ -68,7 +68,8 @@ public class MockInterpreter1 extends Interpreter{
   }
 
   @Override
-  public List<InterpreterCompletion> completion(String buf, int cursor) {
+  public List<InterpreterCompletion> completion(String buf, int cursor,
+      InterpreterContext interpreterContext) {
     return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d398ef2/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index 6a9920a..a453f16 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -640,6 +640,19 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
 
       var remoteCompleter = {
         getCompletions: function(editor, session, pos, prefix, callback) {
+          var langTools = ace.require('ace/ext/language_tools');
+          var defaultKeywords = new Set();
+          var getDefaultKeywords = function(err, completions) {
+              if (completions !== undefined) {
+                  completions.forEach(function(c) {
+                      defaultKeywords.add(c.value);
+                  });
+              }
+          }
+          if (langTools.keyWordCompleter !== undefined) {
+              langTools.keyWordCompleter.getCompletions(editor, session, pos, prefix, getDefaultKeywords);
+          }
+
           if (!editor.isFocused()) {
             return;
           }
@@ -650,13 +663,29 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
           websocketMsgSrv.completion($scope.paragraph.id, buf, pos);
 
           $scope.$on('completionList', function(event, data) {
+            var computeCaption = function(value, meta) {
+              var metaLength = meta !== undefined ? meta.length : 0;
+              var length = 42;
+              var whitespaceLength = 3;
+              var ellipses = '...';
+              var maxLengthCaption = length - metaLength - whitespaceLength - ellipses.length;
+              if (value !== undefined && value.length > maxLengthCaption) {
+                  return value.substr(0, maxLengthCaption) + ellipses;
+              }
+              return value;
+            }
             if (data.completions) {
               var completions = [];
               for (var c in data.completions) {
                 var v = data.completions[c];
+                if (v.meta !== undefined && v.meta === 'keyword' && defaultKeywords.has(v.value.trim()))
{
+                    continue;
+                }
                 completions.push({
                   name: v.name,
                   value: v.value,
+                  meta: v.meta,
+                  caption: computeCaption(v.value, v.meta),
                   score: 300
                 });
               }
@@ -842,7 +871,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
   };
 
   var getInterpreterName = function(paragraphText) {
-    var intpNameRegexp = /^\s*%(.+?)\s/g;
+    var intpNameRegexp = /^\s*%(.+?)(\s|\()/g;
     var match = intpNameRegexp.exec(paragraphText);
     if (match) {
       return match[1].trim();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d398ef2/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
index 894fd19..78a0e8d 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
@@ -20,6 +20,7 @@ package org.apache.zeppelin.notebook;
 import com.google.common.collect.Maps;
 import com.google.common.base.Strings;
 import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.completer.CompletionType;
 import org.apache.zeppelin.display.AngularObject;
 import org.apache.zeppelin.display.AngularObjectRegistry;
 import org.apache.zeppelin.helium.HeliumPackage;
@@ -267,10 +268,11 @@ public class Paragraph extends Job implements Serializable, Cloneable
{
       if (intInfo.size() > 1) {
         for (InterpreterInfo info : intInfo) {
           String name = intp.getName() + "." + info.getName();
-          completion.add(new InterpreterCompletion(name, name));
+          completion.add(new InterpreterCompletion(name, name, CompletionType.setting.name()));
         }
       } else {
-        completion.add(new InterpreterCompletion(intp.getName(), intp.getName()));
+        completion.add(new InterpreterCompletion(intp.getName(), intp.getName(),
+            CompletionType.setting.name()));
       }
     }
     return completion;
@@ -297,7 +299,9 @@ public class Paragraph extends Job implements Serializable, Cloneable
{
       return null;
     }
 
-    List completion = repl.completion(body, cursor);
+    InterpreterContext interpreterContext = getInterpreterContextWithoutRunner(null);
+
+    List completion = repl.completion(body, cursor, interpreterContext);
     return completion;
   }
 
@@ -533,7 +537,9 @@ public class Paragraph extends Job implements Serializable, Cloneable
{
     final Paragraph self = this;
 
     Credentials credentials = note.getCredentials();
-    if (authenticationInfo != null) {
+    setAuthenticationInfo(new AuthenticationInfo(getUser()));
+
+    if (authenticationInfo.getUser() != null) {
       UserCredentials userCredentials =
           credentials.getUserCredentials(authenticationInfo.getUser());
       authenticationInfo.setUserCredentials(userCredentials);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d398ef2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
index e462f72..b16e937 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
@@ -98,7 +98,8 @@ Map<String, Object> vars = new HashMap<>();
 	}
 
 	@Override
-	public List<InterpreterCompletion> completion(String buf, int cursor) {
+	public List<InterpreterCompletion> completion(String buf, int cursor,
+			InterpreterContext interpreterContext) {
 		return null;
 	}
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d398ef2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter11.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter11.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter11.java
index 58200d8..5b9e802 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter11.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter11.java
@@ -76,7 +76,8 @@ public class MockInterpreter11 extends Interpreter{
   }
 
   @Override
-  public List<InterpreterCompletion> completion(String buf, int cursor) {
+  public List<InterpreterCompletion> completion(String buf, int cursor,
+      InterpreterContext interpreterContext) {
     return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d398ef2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
index 93f99ae..7a52f7d 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
@@ -97,7 +97,8 @@ public class MockInterpreter2 extends Interpreter{
 	}
 
 	@Override
-	public List<InterpreterCompletion> completion(String buf, int cursor) {
+	public List<InterpreterCompletion> completion(String buf, int cursor,
+			InterpreterContext interpreterContext) {
 		return null;
 	}
 }


Mime
View raw message