Enhance SQL parsing for UNIQUE constraints and add split_sql_statements - #258
Conversation
|
您好, 还请您花费一点时间审核一下我刚才提的这个pr, 核心是修复这种情况 |
There was a problem hiding this comment.
Pull request overview
This PR improves MySQL DDL query validation by correctly handling semicolons that appear inside quoted strings (e.g., within COMMENT '...'), preventing false “multi-query” rejections.
Changes:
- Added
split_sql_statements(sql)to split semicolon-separated SQL while ignoring semicolons inside',", and`quotes. - Updated
MysqlToClickhouseConverter.__basic_validate_query()to usesplit_sql_statements()instead of a naivefind(';')check.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Use split_sql_statements to correctly ignore semicolons inside quoted strings | ||
| # (e.g. semicolons inside COMMENT '...' clauses are not statement separators) | ||
| if len(split_sql_statements(mysql_query)) > 1: | ||
| print(f'warning: multi-query statement detected, query: {mysql_query}') |
There was a problem hiding this comment.
Add/adjust tests to cover the new multi-statement detection behavior: an ALTER TABLE with a COMMENT string containing a semicolon (e.g. the example in the PR description) should be accepted, while true multi-statement input like "ALTER ...; DROP ..." should still raise. This change is safety-critical because __basic_validate_query now relies on split_sql_statements for correctness.
…identifying non-optimizable table engines and updating database selection logic
|
Sorry for long review. Thanks a lot for contribution! |
Fix: bug
eg: ALTER TABLE backflow_sample_set ADD COLUMN file_path VARCHAR(255) COMMENT '文件路径; 上传文件的存储路径. 上传完毕才会有值'