Skip to content

[Feature-18689][task-flink-sqlgateway] Add FLINK_SGW task plugin - #18690

Closed
macdoor wants to merge 2 commits into
apache:devfrom
macdoor:feature/task-flink-sqlgateway
Closed

macdoor wants to merge 2 commits into
apache:devfrom
macdoor:feature/task-flink-sqlgateway

Conversation

@macdoor

@macdoor macdoor commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Was this PR generated or assisted by AI?

YES — the plugin code was initially developed with AI-assisted tooling (Cursor) and this port/adaptation (rebasing onto dev-SNAPSHOT, adopting the SqlSourceType enum from task-api, refactor for testability, and unit-test authoring) was assisted by an AI agent (Hermes). All changes were human-reviewed and verified by build + unit tests.

Purpose of the pull request

Add a new task plugin FLINK_SGW that submits SQL scripts to a Flink SQL Gateway through its JDBC driver (flink-sql-jdbc-driver), enabling DolphinScheduler to schedule batch SQL workloads without a local Flink client.

The task type is named FLINK_SGW instead of the longer FLINK_SQL_GATEWAY: the long name wraps and breaks the DAG node / task-type picker layout; the short alias reuses the Flink family icon and keeps nodes readable (see linked issue).

Brief change log

  • Add dolphinscheduler-task-flink-sqlgateway module (FlinkSqlGatewayParameters / FlinkSqlGatewayTask / FlinkSqlGatewayTaskChannel / FlinkSqlGatewayTaskChannelFactory)
  • Register the module in dolphinscheduler-task-plugin/pom.xml and wire it into dolphinscheduler-task-all
  • Register FLINK_SGW in task-type-config.yaml
  • UI: task-type constants, store registration, node form fields (use-flink-sqlgateway), format-data serialization, icon fallback (reuse flink.png), locales (en/zh)
  • use-resources field helper gains optional limit / field parameters to support the init-script resource field

Design notes:

  • Script sources reuse org.apache.dolphinscheduler.plugin.task.api.enums.SqlSourceType (SCRIPT / FILE) introduced by [Improvement-18019][task-sql] Support SQL from resource file and parameter placeholders #18020, instead of duplicating constants
  • Init + main script resolution share one code path; statement splitting and comment-stripping are package-private static methods covered by plain JUnit tests (no Mockito)
  • The shaded plugin jar is self-contained (bundles the Flink SQL Gateway JDBC driver); task-api / common stay provided

Verify this pull request

This change added tests and can be verified as follows:

  • mvn test -pl dolphinscheduler-task-plugin/dolphinscheduler-task-flink-sqlgateway -am — FlinkSqlGatewayParametersTest (12 checks: parameter validation across SCRIPT/FILE combinations, resource aggregation, JDBC property filtering) and FlinkSqlGatewayTaskTest (statement splitting incl. regex-special separators, leading comment/blank stripping)
  • mvn package -pl dolphinscheduler-task-plugin/dolphinscheduler-task-flink-sqlgateway -am builds the shaded jar cleanly
  • The plugin binary has been deployed and exercised in an internal production environment since 2026-03 (scheduled batch SQL through a dedicated SQL Gateway), which motivated the naming and the parameter-placeholder handling

Submit SQL scripts to a Flink SQL Gateway via its JDBC driver:

- main/init SQL from inline script or resource-center file
  (reuses task-api SqlSourceType enum)
- configurable statement separator, leading comment/blank stripping
- parameter placeholders supported in jdbc url and scripts
- plain JUnit tests, no Mockito

Named FLINK_SGW because FLINK_SQL_GATEWAY is too long for the DAG
node / task-type picker layout (reuses the Flink family icon).
vue-tsc rejects the task model otherwise; the field is used by the
SQL Gateway form and was missing from ITaskParams.

@SbloodyS SbloodyS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should integrate it into flink task plugin.

@macdoor

macdoor commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

SQL Gateway and the existing Flink SQL path are different runtimes, so this should stay a separate task type.

FlinkTask extends AbstractYarnTask. Its SQL mode always shells out to ${FLINK_HOME}/bin/sql-client.sh on the worker, and cancel/app-id tracking assume a local process. FLINK_SGW talks to a remote Gateway over JDBC (flink-sql-jdbc-driver), needs no local Flink client, and cancels via statement.cancel(). Folding that into programType=SQL or a new deployMode means overriding handle()/cancel() and mixing two parameter models (YARN queue/slots/inline script vs JDBC URL, resource-center files, statement separator). The current sql-client.sh path has to stay; this cannot replace it.

Same split already exists for DINKY (external control plane) and FLINK_STREAM (different lifecycle). task-flink also has no Flink dependencies today. Adding the JDBC driver there would be shaded into task-flink-stream, which depends on task-flink and shades it with no filter.

Happy to colocate both SPI factories in dolphinscheduler-task-flink if the concern is a new Maven module. The task type should remain FLINK_SGW: getName() is persisted on the task definition, and the two execution paths should not share one handle().

@SbloodyS

Copy link
Copy Markdown
Member

I'm -1 on this.

@macdoor

macdoor commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Integrated this into the existing FLINK task plugin, as requested.

sqlSubmitType absent or CLIENT keeps sql-client.sh. SQL_GATEWAY submits over JDBC. Follow-up: #18693

Closing this PR.

@macdoor

macdoor commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favor of #18693.

@macdoor macdoor closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend test UI ui and front end related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants