Fix SQL parser skipping statements that follow comment lines
split(';') produced chunks starting with '--' comment lines, causing
the startsWith('--') check to skip the entire CREATE TABLE statement
for route_executions. Now strips comment lines before splitting.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -66,9 +66,13 @@ public class ClickHouseConfig {
|
||||
// Apply schema files using fully qualified table names
|
||||
for (String schemaFile : SCHEMA_FILES) {
|
||||
String sql = new ClassPathResource(schemaFile).getContentAsString(StandardCharsets.UTF_8);
|
||||
for (String statement : sql.split(";")) {
|
||||
// Strip comment lines before splitting into statements
|
||||
String stripped = sql.lines()
|
||||
.filter(line -> !line.trim().startsWith("--"))
|
||||
.collect(java.util.stream.Collectors.joining("\n"));
|
||||
for (String statement : stripped.split(";")) {
|
||||
String trimmed = statement.trim();
|
||||
if (!trimmed.isEmpty() && !trimmed.startsWith("--")) {
|
||||
if (!trimmed.isEmpty()) {
|
||||
stmt.execute(trimmed);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user