jerry-024 commented on code in PR #271:
URL: https://github.com/apache/paimon-rust/pull/271#discussion_r3121770281
##########
crates/integrations/datafusion/src/sql_handler.rs:
##########
@@ -361,6 +378,171 @@ impl PaimonSqlHandler {
}
}
+/// Quick check whether the SQL looks like a CREATE TABLE statement.
+fn looks_like_create_table(sql: &str) -> bool {
+ let trimmed = sql.trim_start();
+ let upper = &trimmed[..trimmed.len().min(30)];
Review Comment:
This gate fixes the earlier regression for most non-DDL statements, but I
still see two blocking issues here. First, `&trimmed[..trimmed.len().min(30)]`
can panic on a UTF-8 boundary when byte 30 lands in the middle of a multibyte
character (for example: `SELECT aaaaaaaaaaaaaaaaaaaaä¸ć–‡ FROM t`). Second, this
helper skips only leading whitespace, not leading `/* ... */` or `-- ...`
comments, so valid SQL like `/* note */ CREATE TABLE ... PARTITIONED BY (dt)`
will bypass `extract_partition_by` and fall back to the original GenericDialect
parse failure. I think this helper needs to stay byte-based and comment-aware,
or be replaced with a tokenizer/parser-aware check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]