fix: schema initializer skips comment-only SQL segments
The V4 DDL had a semicolon inside a comment which caused the split-on-semicolon logic to produce a comment-only segment that ClickHouse rejected as empty query. Fixed the comment and made the initializer strip comment-only segments before execution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,13 @@ public class ClickHouseSchemaInitializer {
|
|||||||
log.info("Executing ClickHouse schema script: {}", script.getFilename());
|
log.info("Executing ClickHouse schema script: {}", script.getFilename());
|
||||||
for (String statement : sql.split(";")) {
|
for (String statement : sql.split(";")) {
|
||||||
String trimmed = statement.trim();
|
String trimmed = statement.trim();
|
||||||
if (!trimmed.isEmpty()) {
|
// Skip empty segments and comment-only segments
|
||||||
|
String withoutComments = trimmed.lines()
|
||||||
|
.filter(line -> !line.stripLeading().startsWith("--"))
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(line -> !line.isEmpty())
|
||||||
|
.reduce("", (a, b) -> a + b);
|
||||||
|
if (!withoutComments.isEmpty()) {
|
||||||
clickHouseJdbc.execute(trimmed);
|
clickHouseJdbc.execute(trimmed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-- V4__stats_tables_and_mvs.sql
|
-- V4__stats_tables_and_mvs.sql
|
||||||
-- Materialized views replacing TimescaleDB continuous aggregates.
|
-- Materialized views replacing TimescaleDB continuous aggregates.
|
||||||
-- Tables use AggregatingMergeTree; MVs use -State combinators.
|
-- Tables use AggregatingMergeTree, MVs use -State combinators.
|
||||||
|
|
||||||
-- stats_1m_all (global)
|
-- stats_1m_all (global)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user