Task type | Reference Syntax | Description |
Notebook | dlcutils.widgets.get('param_name') | Return the parameter value of the string type. |
SQL | ${param_name} | Replaced directly with the parameter value at runtime. |
value = dlcutils.widgets.get('param_name')
param_name: The parameter name, which corresponds to the Key defined in workflow parameters or task parameters.dp_data_dt = {{workflow.start_time.iso_date}}# Obtain parameter valuesdt = dlcutils.widgets.get('dp_data_dt')print(dt)# Output: 2026-06-11# If numeric values are required, explicitly convert them.batch_size = int(dlcutils.widgets.get('batch_size'))
task_param = {{tasks.upstream_sql.output.first_row.col_a}}col_a_value = dlcutils.widgets.get('task_param')print(col_a_value)# Output: The value of col_a in the first row of the upstream SQL result.
Scenario | Action |
Studio debugging run | If a parameter is not defined, a dialog box prompts the user to manually enter the parameter value. |
Workflow Scheduling Run | The system automatically parses parameter values, and undefined parameters are returned as empty strings. |
${param_name}
${param_name} is directly replaced with the parameter value (string replacement).dp_data_dt = {{workflow.start_time.iso_date}}SELECT *FROM my_tableWHERE dt = '${dp_data_dt}';-- Replaced at runtime with: WHERE dt = '2026-06-11'
target_db = my_databaseUSE ${target_db};SELECT COUNT(*) FROM orders;-- Replaced at runtime with: USE my_database;
SELECT *FROM ${target_db}.${target_table}WHERE dt = '${dp_data_dt}'AND env = '${env}';
Scenario | Action |
Studio debugging run | If a parameter is not defined, a dialog box prompts the user to manually enter the parameter value. |
Workflow Scheduling Run | The system automatically parses parameters. Undefined parameters are replaced with empty strings, which may cause SQL syntax errors. |
Task type | Reference Syntax |
Offline data ingestion | ${param_name} |
Conditional node | ${param_name} |
For Each loop | ${param_name} |
Nested workflow (Run Job) | ${param_name} |
# Workflow parameter definitiondp_data_dt = {{workflow.start_time.iso_date}}
-- Referencing in SQL (Recommended)WHERE dt = '${dp_data_dt}'-- Writing built-in parameters directly in code is not recommended.
# Referencing in Notebook (Recommended)dt = dlcutils.widgets.get('dp_data_dt')
{{workflow.trigger.time.iso_date}} does not support offset operations directly in template syntax. You need to calculate it in your code.trigger_date = {{workflow.trigger.time.iso_date}}
-- Workflow parameter defined: trigger_date = {{workflow.trigger.time.iso_date}}.-- Use the DATE_SUB function to subtract 1 day from the trigger date as the partition time.SELECT *FROM dw.user_dailyWHERE dt = DATE_SUB('${trigger_date}', INTERVAL 1 DAY);-- If the trigger time is 2026-06-12, it is equivalent to: WHERE dt = '2026-06-11'.
DATE_SUB, you can use DATE_ADD instead:WHERE dt = DATE_ADD('${trigger_date}', INTERVAL -1 DAY);
from datetime import datetime, timedelta# Obtain the trigger date from the workflow parameters.trigger_date = dlcutils.widgets.get('trigger_date')# Example of the trigger_date value: '2026-06-12'.# Calculate the previous day as the partition time.dt_obj = datetime.strptime(trigger_date, '%Y-%m-%d')partition_date = (dt_obj - timedelta(days=1)).strftime('%Y-%m-%d')print(partition_date)# Output: 2026-06-11.# Use partition_date for subsequent data reads and writes.spark.sql(f"SELECT * FROM dw.user_daily WHERE dt = '{partition_date}'")
-- String type fields: Add quotes.WHERE dt = '${dp_data_dt}'-- Numeric type fields: Do not add quotes (the parameter value itself is a numeric string).WHERE id = ${target_id}
# String parametersenv = dlcutils.widgets.get('env')# When numeric values are requiredbatch_size = int(dlcutils.widgets.get('batch_size'))threshold = float(dlcutils.widgets.get('threshold'))
import os# In Notebook, you can try to obtain the parameter first, and use the default value if it cannot be obtained.dt = dlcutils.widgets.get('dp_data_dt')if not dt:dt = '2026-06-11' # Default value for development
${param_name} is a plain text substitution in SQL and is not automatically quoted.dp_data_dt and DP_DATA_DT are two different parameters.dlcutils.widgets.get return None or an empty string?${param} not replaced?{{tasks.<name>.values.<key>}} directly in SQL code. The correct approach is as follows:my_param = {{tasks.<name>.values.<key>}}${my_param}피드백