Task Parameter Examples
This page provides complete usage examples for task parameters in common business scenarios, including SQL task and Python task examples, plus a FAQ.
Scenario Examples
Scenario 1: Processing yesterday's partition data
Requirement: Process the previous day's order data every morning.
Parameter configuration: yesterday = $[yyyy-MM-dd, -1d]
If the task runs on 2023-09-22, ${yesterday} is substituted with 2023-09-21.
Scenario 2: Generating a monthly report (last month's data)
Requirement: Generate last month's sales report on the 1st of each month.
Parameter configuration:
last_month_start=first_day_of_month('yyyy-MM-dd', '-1mon')last_month_end=last_day_of_month('yyyy-MM-dd', '-1mon')
If the task runs on 2023-09-01: last_month_start → 2023-08-01, last_month_end → 2023-08-31.
Scenario 3: Weekly report (last Monday through Sunday)
Requirement: Generate last week's user activity report every Monday.
Parameter configuration:
last_week_monday=first_day_of_week('yyyy-MM-dd', '-1w')last_week_sunday=last_day_of_week('yyyy-MM-dd', '-1w')
If the task runs on 2023-09-25 (Monday): last_week_monday → 2023-09-18, last_week_sunday → 2023-09-24.
Scenario 4: Getting every Tuesday's data
Requirement: Periodically analyze Tuesday promotion performance.
Parameter configuration: this_tuesday = get_day_of_week('yyyy-MM-dd', 2)
- Task runs on 2023-09-22 (Friday) →
2023-09-19(this Tuesday) - Task runs on 2023-09-25 (Monday) →
2023-09-26(this Tuesday)
Scenario 5: Timestamp range query (full-day data)
Requirement: Query order data from today 00:00:00 to tomorrow 00:00:00.
Parameter configuration:
today_start=biz_timestamp()tomorrow_start=biz_timestamp(1d)
If the task runs on 2023-09-22: today_start → 1695312000000, tomorrow_start → 1695398400000.
Scenario 6: Using parameters in a Python task
String-type parameters need quotes:
Numeric-type parameters do not need quotes:
Parameter configuration:
yesterday=$[yyyy-MM-dd, -1d]start_ts=biz_timestamp()task_name=sys_task_name
FAQ
Q1: What is the difference between manual run and scheduled run parameters?
| Dimension | Manual run | Scheduled run |
|---|---|---|
| Parameter source | Entered manually in the dialog | Values from the saved parameter configuration |
| Scope | This run only | Every scheduled execution |
| Time reference | The moment you click Run | The scheduled plan time |
sys_task_* parameters | Not supported | Supported |
| Use case | Debugging, validation | Automated production runs |
Parameter values entered during a manual run are not saved to the parameter configuration.
Q2: How do I verify that my parameter configuration is correct?
Run the following in a SQL task to see the substituted result directly:
You can also check the execution log to view the actual SQL that ran and confirm the parameters were substituted correctly.
Q3: How do I handle end-of-month date offset issues?
$[yyyy-MM-dd, -1mon] can be ambiguous at month-end (e.g., January 31 minus 1 month). When you specifically need the last day of the previous month, use last_day_of_month():
Q4: How do I debug complex parameter expressions?
Validate step by step, from simple to complex:
Q5: How do I modify an encrypted parameter?
- Open the parameter configuration and find the encrypted parameter.
- Uncheck "Encrypt value" — the value is displayed in plain text.
- Make your changes, then re-check "Encrypt value".
Encryption only affects how the value is displayed; it does not affect how the parameter is substituted at runtime.
Related Documentation
- Task Parameters — concepts, quick start, parameter types
- Task Parameter Syntax Reference — complete syntax for built-in parameters, time expressions, and time functions
- Task Development and Scheduling — creating and scheduling SQL tasks in Studio
- Workflow (Composite Task) — orchestrate multiple parameterized tasks into a DAG
