You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by we...@apache.org on 2022/12/12 03:07:29 UTC

[dolphinscheduler] branch dev updated: [Bug][Worker] Fix duplicated key bug when have out parameters of same name (#12930)

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

wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 560d232cbd [Bug][Worker] Fix duplicated key bug when have out parameters of same name (#12930)
560d232cbd is described below

commit 560d232cbdea88e3ef1ede51fd55c8eb0e87594d
Author: Aaron Wang <wa...@gmail.com>
AuthorDate: Mon Dec 12 11:07:23 2022 +0800

    [Bug][Worker] Fix duplicated key bug when have out parameters of same name (#12930)
---
 docs/docs/en/guide/parameter/context.md                        |  4 ++++
 docs/docs/zh/guide/parameter/context.md                        | 10 +++++++---
 .../plugin/task/api/parameters/AbstractParameters.java         |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/docs/docs/en/guide/parameter/context.md b/docs/docs/en/guide/parameter/context.md
index 9461969b64..1a48c211ef 100644
--- a/docs/docs/en/guide/parameter/context.md
+++ b/docs/docs/en/guide/parameter/context.md
@@ -17,6 +17,10 @@ DolphinScheduler allows parameter transfer between tasks. Currently, transfer di
 
 When defining an upstream node, if there is a need to transmit the result of that node to a dependency related downstream node. You need to set an `OUT` direction parameter to [Custom Parameters] of the [Current Node Settings]. At present, we mainly focus on the SQL and shell nodes to pass parameters downstream.
 
+The value of upstream parameter can be updated in downstream node in the same way as [setting parameter](#create-a-shell-task-and-set-parameters).
+
+Upstream parameter will be override when defining parameter with the same name in downstream node.
+
 > Note: If there are no dependencies between nodes, local parameters cannot be passed upstream.
 
 ### Example
diff --git a/docs/docs/zh/guide/parameter/context.md b/docs/docs/zh/guide/parameter/context.md
index 59315de550..a80044b1b3 100644
--- a/docs/docs/zh/guide/parameter/context.md
+++ b/docs/docs/zh/guide/parameter/context.md
@@ -17,13 +17,17 @@ DolphinScheduler 允许在任务间进行参数传递,目前传递方向仅支
 
 当定义上游节点时,如果有需要将该节点的结果传递给有依赖关系的下游节点,需要在【当前节点设置】的【自定义参数】设置一个方向是 OUT 的变量。目前我们主要针对 SQL 和 SHELL 节点做了可以向下传递参数的功能。
 
+上游传递的参数可以在下游节点中被更新,更新方法与[设置参数](#创建-shell-任务并设置参数)相同。
+
+如果定义了同名的传递参数,上游节点的参数将被覆盖。
+
 > 注:若节点之间没有依赖关系,则局部参数无法通过上游传递。
 
 ### 任务样例
 
 本样例展示了如何使用参数传递的功能,通过 SHELL 任务来创建本地参数并赋值传递给下游,SQL 任务通过获得上游任务的参数完成查询操作。
 
-#### 创建 SHELL 任务,设置参数
+#### 创建 SHELL 任务并设置参数
 
 > 用户需要传递参数,在定义 SHELL 脚本时,需要输出格式为 ${setValue(key=value)} 的语句,key 为对应参数的 prop,value 为该参数的值。
 
@@ -42,7 +46,7 @@ SHELL 节点定义时当日志检测到 ${setValue(output=1)} 的格式时,会
 
 ![context-parameter02](../../../../img/new_ui/dev/parameter/context_parameter02.png)
 
-#### 创建 SQL 任务,使用参数
+#### 创建 SQL 任务并使用参数
 
 完成上述的 SHELL 任务之后,我们可以使用上游所传递的 output 作为 SQL 的查询对象。其中将所查询的 id 重命名为 ID,作为参数输出。
 
@@ -52,7 +56,7 @@ SHELL 节点定义时当日志检测到 ${setValue(output=1)} 的格式时,会
 >
 > 如果 SQL 节点的结果为多行,一个或多个字段,参数的名字需要和字段名称一致。数据类型选择为 LIST。获取到 SQL 查询结果后会将对应列转化为 LIST,并将该结果转化为 JSON 后作为对应变量的值。
 
-#### 保存工作流,设置全局参数
+#### 保存工作流并设置全局参数
 
 点击保存工作流图标,并设置全局参数 output 和 value。
 
diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java
index 7c0036f630..4e8e2139e6 100644
--- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java
+++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java
@@ -139,7 +139,7 @@ public abstract class AbstractParameters implements IParameters {
             return;
         }
         if (StringUtils.isEmpty(result)) {
-            varPool.addAll(outProperty);
+            outProperty.forEach(this::addPropertyToValPool);
             return;
         }
         Map<String, String> taskResult = getMapByString(result);