You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2021/06/29 03:42:47 UTC

[zeppelin] branch master updated: [ZEPPELIN-5422] Add test for quoted local property in ZSession

This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new e3eebb4  [ZEPPELIN-5422] Add test for quoted local property in ZSession
e3eebb4 is described below

commit e3eebb470ba53e2004a0629573f461a120d61955
Author: Jeff Zhang <zj...@apache.org>
AuthorDate: Wed Jun 23 15:59:54 2021 +0800

    [ZEPPELIN-5422] Add test for quoted local property in ZSession
    
    ### What is this PR for?
    
    This PR add test for quoted local property in ZSession. Besides that it also add method `execute(code, localProperties)` which is missing in the execute api.
    
    ### What type of PR is it?
    [ Improvement ]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-5422
    
    ### 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 <zj...@apache.org>
    
    Closes #4148 from zjffdu/ZEPPELIN-5422 and squashes the following commits:
    
    fb180e28b5 [Jeff Zhang] [ZEPPELIN-5422] Add test for quoted local property value in ZSession
---
 .../src/main/java/org/apache/zeppelin/client/ZSession.java | 14 +++++++++++++-
 .../zeppelin/integration/ZSessionIntegrationTest.java      |  8 ++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/zeppelin-client/src/main/java/org/apache/zeppelin/client/ZSession.java b/zeppelin-client/src/main/java/org/apache/zeppelin/client/ZSession.java
index 9dbcfda..8d50deb 100644
--- a/zeppelin-client/src/main/java/org/apache/zeppelin/client/ZSession.java
+++ b/zeppelin-client/src/main/java/org/apache/zeppelin/client/ZSession.java
@@ -205,6 +205,18 @@ public class ZSession {
    * Run code in non-blocking way.
    *
    * @param code
+   * @param localProperties
+   * @return
+   * @throws Exception
+   */
+  public ExecuteResult execute(String code, Map<String, String> localProperties) throws Exception {
+    return execute("", localProperties, code);
+  }
+
+  /**
+   * Run code in non-blocking way.
+   *
+   * @param code
    * @param messageHandler
    * @return
    * @throws Exception
@@ -270,7 +282,7 @@ public class ZSession {
     if (localProperties != null && !localProperties.isEmpty()) {
       builder.append("(");
       List<String> propertyString = localProperties.entrySet().stream()
-              .map(entry -> (entry.getKey() + "=\"" + entry.getValue() + "\""))
+              .map(entry -> ("\"" + entry.getKey() + "\"=\"" + entry.getValue() + "\""))
               .collect(Collectors.toList());
       builder.append(StringUtils.join(propertyString, ","));
       builder.append(")");
diff --git a/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZSessionIntegrationTest.java b/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZSessionIntegrationTest.java
index 07bb036..0fe8673 100644
--- a/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZSessionIntegrationTest.java
+++ b/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZSessionIntegrationTest.java
@@ -427,6 +427,14 @@ public class ZSessionIntegrationTest extends AbstractTestRestApi {
       assertEquals(result.toString(), Status.FINISHED, result.getStatus());
       assertEquals(1, result.getResults().size());
       assertEquals("TEXT", result.getResults().get(0).getType());
+
+      Map<String, String> localProperties = new HashMap<>();
+      localProperties.put("key 1", "hello world"); // contains whitespace
+      localProperties.put("key,2", "a,b"); // contains comma
+      result = session.execute("1+1", localProperties);
+      assertEquals(result.toString(), Status.FINISHED, result.getStatus());
+      assertEquals(1, result.getResults().size());
+      assertEquals("TEXT", result.getResults().get(0).getType());
     } finally {
       session.stop();
     }