Skip to content

Commit

Permalink
[ZEPPELIN-5052]. Unable to set multiple local properties in ZSession
Browse files Browse the repository at this point in the history
### What is this PR for?

The root cause is that the local properties format is not correct, we should separate them via dot.  This PR fix it and also add unit test for this scenario.

### What type of PR is it?
[Bug Fix ]

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-5052

### How should this be tested?
* CI pass

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jeff Zhang <[email protected]>

Closes apache#3916 from zjffdu/ZEPPELIN-5052 and squashes the following commits:

08229d9 [Jeff Zhang] [ZEPPELIN-5052]. Unable to set multiple local properties in ZSession
  • Loading branch information
zjffdu committed Sep 20, 2020
1 parent 7ca1409 commit d6ea950
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Each ZSession represent one interpreter process, you can start/stop it, and execute/submit/cancel code.
Expand Down Expand Up @@ -263,9 +265,10 @@ public ExecuteResult execute(String subInterpreter,
}
if (localProperties != null && !localProperties.isEmpty()) {
builder.append("(");
for (Map.Entry<String, String> entry : localProperties.entrySet()) {
builder.append(entry.getKey() + "=\"" + entry.getValue() + "\"");
}
List<String> propertyString = localProperties.entrySet().stream()
.map(entry -> (entry.getKey() + "=\"" + entry.getValue() + "\""))
.collect(Collectors.toList());
builder.append(StringUtils.join(propertyString, ","));
builder.append(")");
}
builder.append("\n" + code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ public void testZSession_Flink() throws Exception {
assertEquals(result.toString(), Status.FINISHED, result.getStatus());
Map<String, String> localProperties = new HashMap<>();
localProperties.put("type", "update");
localProperties.put("parallelism", "2");
result = session.execute("ssql", localProperties, "select url, count(1) as pv from log group by url");
assertEquals(result.toString(), Status.FINISHED, result.getStatus());

Expand Down

0 comments on commit d6ea950

Please sign in to comment.