-
Notifications
You must be signed in to change notification settings - Fork 5k
[Fix-17040][sql] Preserve PL/pgSQL DO $$ blocks in PostgreSQL SQL splitting #17145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md) |
|
Hi @chaz6chez @SbloodyS 👋 This PR addresses issue #17040 by correctly handling PostgreSQL
Please have a look when you get time. Would love your feedback 🙌 |
4676e86 to
e837391
Compare
|
Hi @SbloodyS, I’ve pushed the latest changes with spotless and license fixes — all set now. |
I'm not quite familiar with postgresql. PTAL @Gallardot @ruanwenjun @caishunfeng |
ruanwenjun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR.
.../apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceProcessorTest.java
Outdated
Show resolved
Hide resolved
e837391 to
1492558
Compare
|
Hi @ruanwenjun and @SbloodyS — I’ve pushed the latest changes to address the review feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the incorrect splitting of PL/pgSQL DO $$ blocks in PostgreSQL SQL tasks. The changes include overriding the splitAndRemoveComment() method with a custom splitter that preserves dollar-quoted blocks and adding unit tests to verify the behavior.
- Override splitAndRemoveComment() in PostgreSQLDataSourceProcessor to use a custom splitter.
- Implement a dollar-quote-aware SQL splitting algorithm.
- Add comprehensive unit tests for various PL/pgSQL and standard SQL scripts.
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceProcessorTest.java | Added unit tests for DO block and standard SQL splitting scenarios |
| dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/main/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/param/PostgreSQLDataSourceProcessor.java | Replaces Druid-based SQL splitting with a custom implementation that preserves dollar-quoted blocks |
Files not reviewed (1)
- .idea/vcs.xml: Language not supported
...pache/dolphinscheduler/plugin/datasource/postgresql/param/PostgreSQLDataSourceProcessor.java
Outdated
Show resolved
Hide resolved
.../apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceProcessorTest.java
Show resolved
Hide resolved
.../apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceProcessorTest.java
Show resolved
Hide resolved
.../apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceProcessorTest.java
Show resolved
Hide resolved
1492558 to
af8f71c
Compare
…ring SQL splitting
af8f71c to
c426b95
Compare
|
Hi @ruanwenjun, I’ve updated the logic based on a suggestion from Copilot and adjusted the test cases as per your feedback. I’ve also added a few more test cases to cover additional edge scenarios. Hopefully, everything looks good now and this finalises the PR. |
ruanwenjun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
SbloodyS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
Awesome work, congrats on your first merged pull request! |
…ring SQL splitting (apache#17145)



Purpose of the pull request
Fixes issue #17040
This PR fixes incorrect splitting of PL/pgSQL
DO $$...$$;blocks in PostgreSQL SQL tasks.Root cause
The regression was introduced in #15367, which enabled Druid-based SQL splitting.
However, Druid's default SQL parser splits on semicolons — including those inside dollar-quoted
DO $$...$$blocks — which breaks valid PL/pgSQL scripts by triggering errors likeUnterminated dollar quote.Brief change log
splitAndRemoveComment()inPostgreSQLDataSourceProcessorDO $$ ... $$blocksVerify this pull request
This change added tests and can be verified as follows:
DO $$ ... $$;blockDOblock followed byINSERTandUPDATEPostgreSQLDataSourceProcessorTest:$func$)Documentation
This pull request does not require documentation update — it only fixes internal SQL splitting logic for PostgreSQL.
Incompatible Changes
This PR does not introduce any incompatible changes.