Files
doc-exports/docs/dataartsstudio/umn/dataartsstudio_01_7524.html
chenxiaoxiong f9e2808b7c DataArts UMN 20250810 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: chenxiaoxiong <chenxiaoxiong@huawei.com>
Co-committed-by: chenxiaoxiong <chenxiaoxiong@huawei.com>
2025-09-02 10:44:13 +00:00

105 lines
17 KiB
HTML

<a name="dataartsstudio_01_7524"></a><a name="dataartsstudio_01_7524"></a>
<h1 class="topictitle1">Referencing Parameters in Scripts and Jobs</h1>
<div id="body0000001540978525"><p id="dataartsstudio_01_7524__p351215339324">This section describes how to reference parameters in scripts and jobs, application scope of the referenced parameters, and whether EL expressions and simple variable sets are supported, helping you better understand how to use workspace-level, script-level, and job-level parameters.</p>
<div class="note" id="dataartsstudio_01_7524__note1447775713555"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dataartsstudio_01_7524__p047811573555">The application scopes of workspace environment variables, job parameters, and script parameters are different. If a workspace environment variable, a job parameter, and a script parameter have the same name, their priorities are as follows: <strong id="dataartsstudio_01_7524__b8701105713585">job parameter &gt; workspace environment variable &gt; script parameter</strong>.</p>
</div></div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dataartsstudio_01_7524__table6363132353" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Methods of using parameters</caption><thead align="left"><tr id="dataartsstudio_01_7524__row19363832259"><th align="left" class="cellrowborder" valign="top" width="20.822316234796407%" id="mcps1.3.3.2.5.1.1"><p id="dataartsstudio_01_7524__p13363732658">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36.63405605499736%" id="mcps1.3.3.2.5.1.2"><p id="dataartsstudio_01_7524__p636312321459">Scenario</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.309360126916976%" id="mcps1.3.3.2.5.1.3"><p id="dataartsstudio_01_7524__p53639325519">Scope</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="27.234267583289263%" id="mcps1.3.3.2.5.1.4"><p id="dataartsstudio_01_7524__p1336311329515">Calling Method</p>
</th>
</tr>
</thead>
<tbody><tr id="dataartsstudio_01_7524__row17081515153711"><td class="cellrowborder" valign="top" width="20.822316234796407%" headers="mcps1.3.3.2.5.1.1 "><p id="dataartsstudio_01_7524__p445742953715">Environment variables/constants</p>
</td>
<td class="cellrowborder" valign="top" width="36.63405605499736%" headers="mcps1.3.3.2.5.1.2 "><p id="dataartsstudio_01_7524__p745713298377">When configuring job parameters, you can extract a parameter that belongs to multiple jobs as an environment variable.</p>
</td>
<td class="cellrowborder" valign="top" width="15.309360126916976%" headers="mcps1.3.3.2.5.1.3 "><p id="dataartsstudio_01_7524__p1045752912372">Current workspace</p>
</td>
<td class="cellrowborder" valign="top" width="27.234267583289263%" headers="mcps1.3.3.2.5.1.4 "><p id="dataartsstudio_01_7524__p045782917372">${<em id="dataartsstudio_01_7524__i145762916371">Environment variable</em>}</p>
<p id="dataartsstudio_01_7524__p14822111254618">${<em id="dataartsstudio_01_7524__i1722251813911">Environment constant</em>}</p>
<p id="dataartsstudio_01_7524__p1457182910373">For details about the configuration method, see <a href="#dataartsstudio_01_7524__section22181399319">Environment Variable</a>.</p>
</td>
</tr>
<tr id="dataartsstudio_01_7524__row1336493219519"><td class="cellrowborder" valign="top" width="20.822316234796407%" headers="mcps1.3.3.2.5.1.1 "><p id="dataartsstudio_01_7524__p43641321656">Job variables/constants</p>
</td>
<td class="cellrowborder" valign="top" width="36.63405605499736%" headers="mcps1.3.3.2.5.1.2 "><p id="dataartsstudio_01_7524__p16761122303112">Job parameters can be used in any node in jobs.</p>
</td>
<td class="cellrowborder" valign="top" width="15.309360126916976%" headers="mcps1.3.3.2.5.1.3 "><p id="dataartsstudio_01_7524__p84461743131110">Current job</p>
</td>
<td class="cellrowborder" valign="top" width="27.234267583289263%" headers="mcps1.3.3.2.5.1.4 "><p id="dataartsstudio_01_7524__p12897113916811">${<em id="dataartsstudio_01_7524__i1993182112255">Job variable</em>}</p>
<p id="dataartsstudio_01_7524__p17681152115610">${<em id="dataartsstudio_01_7524__i697501191117">Job constant</em>}</p>
<p id="dataartsstudio_01_7524__p1736419321520">For details about the configuration method, see <a href="#dataartsstudio_01_7524__section56401130635">Configuring Job Parameters</a>.</p>
</td>
</tr>
<tr id="dataartsstudio_01_7524__row3365732551"><td class="cellrowborder" valign="top" width="20.822316234796407%" headers="mcps1.3.3.2.5.1.1 "><p id="dataartsstudio_01_7524__p163651327514">Script parameters</p>
</td>
<td class="cellrowborder" valign="top" width="36.63405605499736%" headers="mcps1.3.3.2.5.1.2 "><p id="dataartsstudio_01_7524__en-us_topic_0099797007_p17761952813">Set the name and value of a custom field.</p>
</td>
<td class="cellrowborder" valign="top" width="15.309360126916976%" headers="mcps1.3.3.2.5.1.3 "><p id="dataartsstudio_01_7524__p4365203218515">Current script</p>
</td>
<td class="cellrowborder" valign="top" width="27.234267583289263%" headers="mcps1.3.3.2.5.1.4 "><p id="dataartsstudio_01_7524__p16629759122617">${<em id="dataartsstudio_01_7524__i825163391215">Script parameter</em>}</p>
<p id="dataartsstudio_01_7524__p1036543212511">For details about the configuration method, see <a href="#dataartsstudio_01_7524__section04082466318">Script Parameter</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="dataartsstudio_01_7524__note2539231303"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dataartsstudio_01_7524__p10577321133210">Variables of an SQL script can be in ${} or ${dlf.} format. You can configure either type as needed. The configured variable format applies to SQL scripts, SQL statements in jobs, single-node jobs, and environment variables. For details about how to configure the script variable format, see <a href="dataartsstudio_01_04501.html#dataartsstudio_01_04501__section310213518565">Configuring Script Variables</a>.</p>
<p id="dataartsstudio_01_7524__p1163575314566">The default variable format is <strong id="dataartsstudio_01_7524__b1233353015113734">${}</strong>.</p>
</div></div>
<div class="section" id="dataartsstudio_01_7524__section22181399319"><a name="dataartsstudio_01_7524__section22181399319"></a><a name="section22181399319"></a><h4 class="sectiontitle">Environment Variable</h4><div class="p" id="dataartsstudio_01_7524__p9562125912520">Variables and constants can be defined in environment variables. Environment variables take effect in current workspace.<ul id="dataartsstudio_01_7524__ul1820541115111"><li id="dataartsstudio_01_7524__li37701612174915">The value of a variable (such as <strong id="dataartsstudio_01_7524__b1517477717103019">workspace name</strong>) varies depending on the workspace. When exporting a variable from a workspace and import it to another workspace, you must reconfigure its value.</li><li id="dataartsstudio_01_7524__li3770212144914">The value of a constant in different workspaces is the same. When importing a constant to another workspace, you do not need to reconfigure its value.</li></ul>
<div class="fignone" id="dataartsstudio_01_7524__fig232910462147"><span class="figcap"><b>Figure 1 </b>Environment Variable</span><br><span><img id="dataartsstudio_01_7524__image563911351146" src="en-us_image_0000002234236216.png" title="Click to enlarge" class="imgResize"></span></div>
</div>
<p id="dataartsstudio_01_7524__p725232018135"></p>
<p id="dataartsstudio_01_7524__p147873332042">The specific application is as follows:</p>
<p id="dataartsstudio_01_7524__p135421243175219">An environment variable has been added. The parameter name is <span class="parmvalue" id="dataartsstudio_01_7524__parmvalue74051591517"><b>sdqw</b></span> and the parameter value is <span class="parmvalue" id="dataartsstudio_01_7524__parmvalue124057594512"><b>wqewqewqe</b></span>.</p>
<ol id="dataartsstudio_01_7524__en-us_topic_0175328117_ol10416315219"><li id="dataartsstudio_01_7524__en-us_topic_0175328117_li15416312027"><span>Open a created job and drag a <span class="parmvalue" id="dataartsstudio_01_7524__en-us_topic_0175328117_parmvalue741641320"><b>Create OBS</b></span> node from the node library to the canvas.</span></li><li id="dataartsstudio_01_7524__en-us_topic_0175328117_li15416011921"><span>On the <strong id="dataartsstudio_01_7524__b1995835037113734">Node Properties</strong> tab page, configure the node properties.</span><p><div class="fignone" id="dataartsstudio_01_7524__en-us_topic_0175328117_fig141771124"><span class="figcap"><b>Figure 2 </b>Create OBS</span><br><span><img id="dataartsstudio_01_7524__image20801851113" src="en-us_image_0000002269195693.png"></span></div>
<p id="dataartsstudio_01_7524__p17875104071613"></p>
</p></li><li id="dataartsstudio_01_7524__en-us_topic_0175328117_li17417811620"><span>Click <span class="uicontrol" id="dataartsstudio_01_7524__uicontrol1787702388113734"><b>Save</b></span> and then <span class="uicontrol" id="dataartsstudio_01_7524__uicontrol2074647290113734"><b>Monitor</b></span> to monitor the running status of the job.</span></li></ol>
</div>
<div class="section" id="dataartsstudio_01_7524__section56401130635"><a name="dataartsstudio_01_7524__section56401130635"></a><a name="section56401130635"></a><h4 class="sectiontitle">Configuring Job Parameters</h4><div class="p" id="dataartsstudio_01_7524__p1731193112317">Variables and constants can be defined in job parameters. Job parameters take effect in the current job.<ul id="dataartsstudio_01_7524__ul1037642812016"><li id="dataartsstudio_01_7524__li1637619280015">The value of a variable varies depending on the job. You need to configure a value for the variable in each job.</li><li id="dataartsstudio_01_7524__li19376122817016">The value of a constant in different jobs is the same. When importing a constant to another job, you do not need to reconfigure its value.<div class="fignone" id="dataartsstudio_01_7524__fig73194171011"><span class="figcap"><b>Figure 3 </b>Job parameter.</span><br><span><img id="dataartsstudio_01_7524__image23118421014" src="en-us_image_0000002234076400.png" title="Click to enlarge" class="imgResize"></span></div>
<p id="dataartsstudio_01_7524__p1808175841018"></p>
<p id="dataartsstudio_01_7524__p1120715430111">After a job parameter is defined, it can be referenced by a job node.</p>
<div class="fignone" id="dataartsstudio_01_7524__fig148351812191515"><span class="figcap"><b>Figure 4 </b>Using a Job Parameter Configuration</span><br><span><img id="dataartsstudio_01_7524__image39942075156" src="en-us_image_0000002269115597.png" title="Click to enlarge" class="imgResize"></span></div>
<p id="dataartsstudio_01_7524__p458355613155"></p>
</li></ul>
</div>
</div>
<div class="section" id="dataartsstudio_01_7524__section04082466318"><a name="dataartsstudio_01_7524__section04082466318"></a><a name="section04082466318"></a><h4 class="sectiontitle">Script Parameter</h4><ul id="dataartsstudio_01_7524__ul37708127499"><li id="dataartsstudio_01_7524__li663273618147">Script parameters take effect in current script and it can be used in the following ways.<ul id="dataartsstudio_01_7524__ul181981512181517"><li id="dataartsstudio_01_7524__li17521155914142">For SQL scripts, you can directly enter parameters in the script editor (not supported for Flink SQL scripts). During job scheduling, you can assign values to parameters through node attributes, as shown in <a href="#dataartsstudio_01_7524__li14638161911311">2</a>.</li><li id="dataartsstudio_01_7524__li10645420174515">For Shell scripts, you can enter a parameter and an interactive parameter in the upper part of the editor to transfer the parameters.</li><li id="dataartsstudio_01_7524__li11521145915141">Python scripts support parameter transfer.</li><li id="dataartsstudio_01_7524__li1638611453">For SQL scripts, you can directly enter parameters in the script editor (not supported for Flink SQL scripts). When executing a script independently, you can configure parameters in the lower part of the editor shown in <a href="#dataartsstudio_01_7524__fig35061784103">Figure 5</a>.<div class="fignone" id="dataartsstudio_01_7524__fig35061784103"><a name="dataartsstudio_01_7524__fig35061784103"></a><a name="fig35061784103"></a><span class="figcap"><b>Figure 5 </b>Configuring script parameters when executing a script independently</span><br><span><img id="dataartsstudio_01_7524__image1560544505913" src="en-us_image_0000002269195641.png" title="Click to enlarge" class="imgResize"></span></div>
<p id="dataartsstudio_01_7524__p16444123311252"></p>
</li></ul>
</li></ul>
<ol id="dataartsstudio_01_7524__ol0102326115819"><li id="dataartsstudio_01_7524__li193611632">Developing a Python Script During script development, the script expression must contain variables. For example, if the variable in the SQL statement is DATE, set this parameter to ${DATE} in the script. In the job parameter configuration, you can compile the statement expression of the script parameter Date in <a href="#dataartsstudio_01_7524__li14638161911311">2</a>.<div class="p" id="dataartsstudio_01_7524__p8816953212">On the <span class="uicontrol" id="dataartsstudio_01_7524__uicontrol12824953218"><b>script development</b></span> page, enter development statements in the editor, as shown in the following figure.<pre class="screen" id="dataartsstudio_01_7524__screen118211953219">INSERT INTO B FROM (SELECT * FROM A WHERE DATE = ${DATE})</pre>
<div class="fignone" id="dataartsstudio_01_7524__fig48214918321"><span class="figcap"><b>Figure 6 </b>Developing a script</span><br><span><img id="dataartsstudio_01_7524__image148216983219" src="en-us_image_0000002269195669.png" title="Click to enlarge" class="imgResize"></span></div>
</div>
<p id="dataartsstudio_01_7524__p1882109153218"></p>
<p id="dataartsstudio_01_7524__p2943141911144">After the dws_030903 script is compiled, save and submit the latest version of the script.</p>
</li><li id="dataartsstudio_01_7524__li14638161911311"><a name="dataartsstudio_01_7524__li14638161911311"></a><a name="li14638161911311"></a>Develop batch jobs. When developing a job, you need to configure node attribute parameters.<p id="dataartsstudio_01_7524__p538549123316"><a name="dataartsstudio_01_7524__li14638161911311"></a><a name="li14638161911311"></a>In the left navigation pane of DataArts Factory, choose <span class="menucascade" id="dataartsstudio_01_7524__menucascade1715484548103019"><b><span class="uicontrol" id="dataartsstudio_01_7524__uicontrol1990540369103019"><span id="dataartsstudio_01_7524__text1678703487103019">Data Development</span></span></b> &gt; <b><span class="uicontrol" id="dataartsstudio_01_7524__uicontrol221192605103019"><span id="dataartsstudio_01_7524__text1781849003103019">Develop Job</span></span></b></span>.</p>
<div class="fignone" id="dataartsstudio_01_7524__fig161651455153213"><span class="figcap"><b>Figure 7 </b>Configuring script parameters when the script is executed by job scheduling</span><br><span><img id="dataartsstudio_01_7524__image1165955133219" src="en-us_image_0000002269115569.png" title="Click to enlarge" class="imgResize"></span></div>
<p id="dataartsstudio_01_7524__p5165135563219"></p>
<div class="note" id="dataartsstudio_01_7524__note716625518325"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="dataartsstudio_01_7524__ul81661355143217"><li id="dataartsstudio_01_7524__li41651855113217">If the associated SQL script uses a parameter, the parameter name is displayed (<strong id="dataartsstudio_01_7524__b07836539185">DATA</strong> for example). Set the parameter value in the text box next to the parameter name. The parameter value can be <a href="dataartsstudio_01_0494.html">an EL expression</a>.</li><li id="dataartsstudio_01_7524__li1916535514324">If the associated SQL script or script parameters change, you can click <span><img id="dataartsstudio_01_7524__image516555510324" src="en-us_image_0000002234076364.png"></span> to synchronize the changes or click <span><img id="dataartsstudio_01_7524__image916535517326" src="en-us_image_0000002269115617.png"></span> to edit the changes.</li><li id="dataartsstudio_01_7524__li443015011197">All nodes involving scripts, such as SQL scripts, shell scripts, and Python scripts, can use this method to reference script variables.</li></ul>
</div></div>
</li></ol>
</div>
<div class="section" id="dataartsstudio_01_7524__section16863441947"><h4 class="sectiontitle">Simple Variable Set</h4><p id="dataartsstudio_01_7524__p108959514417">The simple variable set provides a series of customized variables. Customized parameters are automatically replaced with specific values based on the service date, plan time, and parameter value format of task scheduling. In this way, parameters can be dynamically replaced during task scheduling. For details about the simple variable set, see <a href="dataartsstudio_01_0556.html">Simple Variable Set</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dataartsstudio_01_0520.html">Usage Guidance</a></div>
</div>
</div>
<script language="JavaScript">
<!--
initImageViewer('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>