Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ public List<InterpreterCompletion> completion(String buf, int cursor) {
statementSetNotifier.notify();
}

String[] completionList = null;
synchronized (statementFinishedNotifier) {
long startTime = System.currentTimeMillis();
while (statementOutput == null
&& pythonScriptInitialized == false
&& pythonscriptRunning) {
try {
if (System.currentTimeMillis() - startTime < MAX_TIMEOUT_SEC * 1000) {
if (System.currentTimeMillis() - startTime > MAX_TIMEOUT_SEC * 1000) {
logger.error("pyspark completion didn't have response for {}sec.", MAX_TIMEOUT_SEC);
break;
}
Expand All @@ -447,16 +447,20 @@ public List<InterpreterCompletion> completion(String buf, int cursor) {
return new LinkedList<>();
}
}
if (statementError) {
return new LinkedList<>();
}
InterpreterResult completionResult;
completionResult = new InterpreterResult(Code.SUCCESS, statementOutput);
Gson gson = new Gson();
completionList = gson.fromJson(completionResult.message(), String[].class);
}
//end code for completion

if (statementError) {
if (completionList == null) {
return new LinkedList<>();
}
InterpreterResult completionResult = new InterpreterResult(Code.SUCCESS, statementOutput);
//end code for completion

Gson gson = new Gson();
String[] completionList = gson.fromJson(completionResult.message(), String[].class);
List<InterpreterCompletion> results = new LinkedList<>();
for (String name: completionList) {
results.add(new InterpreterCompletion(name, name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.zeppelin.interpreter.InterpreterOutputListener;
import org.apache.zeppelin.interpreter.InterpreterOutput;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.resource.LocalResourcePool;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.junit.After;
Expand All @@ -37,6 +38,7 @@
import java.io.File;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;

import static org.junit.Assert.*;
Expand Down Expand Up @@ -144,4 +146,11 @@ public void testBasicIntp() {
}
}

@Test
public void testCompletion() {
if (getSparkVersionNumber() > 11) {
List<InterpreterCompletion> completions = pySparkInterpreter.completion("sc.", "sc.".length());
assertTrue(completions.size() > 0);
}
}
}