matrixorigin / matrixorigin/matrixone
[Bug] OmniFabric Workbook UI splits SQL on `;` even inside `--` comments
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 311
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 768
Description
## Version
MatrixOne **v3.0.11** / OmniFabric Workbook UI (latest)
## Summary
The Workbook UI's SQL statement splitter uses a naive `;`-based split that **does not honor SQL comments**. Any semicolon inside a `--` line comment is treated as a statement separator, causing the comment to be broken across multiple "statements" and resulting in parse errors.
This prevents users from documenting their workbooks with explanatory comments that contain SQL fragments (a common practice for tutorial/demo content).
## Reproduction
Workbook content:
```sql
-- This view shows how to compute MTBF; useful for reliability analysis.
SELECT pump, mtbf_minutes FROM gold_pump_kpis;
```
The Workbook UI splits this into:
1. `-- This view shows how to compute MTBF`
2. `useful for reliability analysis.\nSELECT pump, mtbf_minutes FROM gold_pump_kpis`
Statement #2 fails with a parser error because `useful for ...` is not valid SQL.
## Real-World Impact
In our customer POC's Workbook 04 (TASK scheduling demo), we wanted to show the full `CREATE TASK` DDL as a reference inside `--` comments (since the DDL contains `BEGIN...END` with embedded `;` that the Workbook UI can't execute anyway). Every single `;` inside the commented DDL had to be manually removed, even though they are inside `--` comments. Example before fix:
```sql
-- CREATE TASK task_build_silver
-- SCHEDULE '0 */1 * * * *'
-- AS
-- BEGIN
-- TRUNCATE silver_x; -- this ';' breaks the workbook
-- INSERT INTO silver_x ...; -- and this one
-- END
```
The entire commented-out DDL had to be rewritten to remove every internal `;`, making it less readable and not copy-pasteable.
## Expected Behavior
The Workbook UI's statement splitter should be **SQL-aware**:
1. `;` inside `-- line comment` is ignored
2. `;` inside `/* block comment */` is ignored
3. `;` inside `'string literal'` or `"string literal"` is ignored
4. `;` inside `DELIMITER $$ ... $$` regions is ignored
## Actual Behavior
Naive `\bs+\;` split — any `;` is a hard statement boundary, regardless of context.
## Suggested Fix
Replace the splitter with a token-based scanner that tracks comment / string / DELIMITER state. Most SQL clients (mycli, dbeaver, jetbrains) handle this correctly and can be used as reference implementations.
A pure-JS minimal implementation looks like ~50 lines.
## Environment
- MatrixOne v3.0.11
- Workbook UI (latest version as of customer POC, deployed via OmniFabric console)
Contributor guide
Assessment
This issue has not been assessed yet.