Search before asking
Description
Purpose
Using Resource Center SQL files makes it much easier to manage SQL scripts:
- SQL scripts can be version-controlled and reviewed independently (e.g. via Git)
- Multiple workflows can share the same SQL file, avoiding duplication
- Updating SQL logic only requires updating the file, without editing every SQL task node
Extend the SQL task type to support:
- Executing SQL from a Resource Center file (in addition to inline script)
- Applying parameter placeholders (
${...}, $[...]) consistently for both inline SQL and file-based SQL
This is similar to what other task types already support (e.g. HiveCli, Shell, Spark, Python, Flink/FlinkSqlGateway).
Background
In current dev:
SqlParameters only has a single sql field
- The SQL task UI only supports inline SQL text
- Users who keep large SQL scripts in the Resource Center cannot reference them directly from the SQL task
- Parameter placeholder replacement is partially handled when binding parameters, but there is no way to:
- load SQL content from a file first
- then apply placeholders on that content
For large / shared SQL scripts, putting them into the Resource Center and referencing them from tasks is a common pattern. Tasks like HiveCli, Shell, Spark, Python already support this mode.
Proposal
Backend
-
Extend SqlParameters (dolphinscheduler-task-api):
- Add fields:
sqlSource: "SCRIPT" (default) or "FILE"
sqlResource: resource path in Resource Center
- Keep existing
sql for inline SQL (backward compatible).
- Update:
checkParameters() to accept either sql OR sqlResource
getResourceFilesList() to return a ResourceInfo when sqlResource is set, so Worker downloads the file
-
Extend SqlTask (dolphinscheduler-task-sql):
-
Before splitting SQL, ensure SQL content:
private void ensureSqlContent() {
if (StringUtils.isNotEmpty(sqlParameters.getSql())) {
return;
}
if (StringUtils.isEmpty(sqlParameters.getSqlResource())) {
return;
}
// Use TaskExecutionContext.getResourceContext()
// to resolve local path and read SQL text into sqlParameters.sql
}
Are you willing to submit a PR?
Code of Conduct
Search before asking
Description
Purpose
Using Resource Center SQL files makes it much easier to manage SQL scripts:
Extend the SQL task type to support:
${...},$[...]) consistently for both inline SQL and file-based SQLThis is similar to what other task types already support (e.g. HiveCli, Shell, Spark, Python, Flink/FlinkSqlGateway).
Background
In current
dev:SqlParametersonly has a singlesqlfieldFor large / shared SQL scripts, putting them into the Resource Center and referencing them from tasks is a common pattern. Tasks like HiveCli, Shell, Spark, Python already support this mode.
Proposal
Backend
Extend
SqlParameters(dolphinscheduler-task-api):sqlSource:"SCRIPT"(default) or"FILE"sqlResource: resource path in Resource Centersqlfor inline SQL (backward compatible).checkParameters()to accept eithersqlORsqlResourcegetResourceFilesList()to return aResourceInfowhensqlResourceis set, so Worker downloads the fileExtend
SqlTask(dolphinscheduler-task-sql):Before splitting SQL, ensure SQL content:
private void ensureSqlContent() {
if (StringUtils.isNotEmpty(sqlParameters.getSql())) {
return;
}
if (StringUtils.isEmpty(sqlParameters.getSqlResource())) {
return;
}
// Use TaskExecutionContext.getResourceContext()
// to resolve local path and read SQL text into sqlParameters.sql
}
Are you willing to submit a PR?
Code of Conduct