diff --git a/sqrl-planner/src/main/java/com/datasqrl/engine/database/relational/ddl/PostgresCreateTableDdlFactory.java b/sqrl-planner/src/main/java/com/datasqrl/engine/database/relational/ddl/PostgresCreateTableDdlFactory.java index 6ececbba3..4d48de3de 100644 --- a/sqrl-planner/src/main/java/com/datasqrl/engine/database/relational/ddl/PostgresCreateTableDdlFactory.java +++ b/sqrl-planner/src/main/java/com/datasqrl/engine/database/relational/ddl/PostgresCreateTableDdlFactory.java @@ -48,6 +48,13 @@ public String createTableDdl(CreateTableJdbcStatement stmt) { return partitionDdl; } + // pg_partman owns lifecycle for RANGE+TTL tables — no default partition needed + if (stmt.getPartitionType() == PartitionType.RANGE + && stmt.getTtl() != null + && !stmt.getTtl().isZero()) { + return partitionDdl; + } + var allPartitionTableName = quoteIdentifier(stmt.getName() + PARTITION_SUFFIX); var tableName = quoteIdentifier(stmt.getName()); var partitionDefinition = diff --git a/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/DAGPlannerTest/partitionTest.txt b/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/DAGPlannerTest/partitionTest.txt index 29e820b5a..f3b317925 100644 --- a/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/DAGPlannerTest/partitionTest.txt +++ b/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/DAGPlannerTest/partitionTest.txt @@ -179,7 +179,7 @@ INSERT INTO `default_catalog`.`default_database`.`Orders_2` { "name" : "OrderUpdates_1", "type" : "TABLE", - "sql" : "CREATE TABLE IF NOT EXISTS \"OrderUpdates_1\" (\"id\" BIGINT NOT NULL, \"customerid\" BIGINT NOT NULL, \"time\" TIMESTAMP WITH TIME ZONE NOT NULL, \"entries\" JSONB, PRIMARY KEY (\"id\",\"time\")) PARTITION BY RANGE (\"time\");\n\nCREATE TABLE IF NOT EXISTS \"OrderUpdates_1_all\" PARTITION OF \"OrderUpdates_1\" FOR VALUES FROM (MINVALUE) TO (MAXVALUE)", + "sql" : "CREATE TABLE IF NOT EXISTS \"OrderUpdates_1\" (\"id\" BIGINT NOT NULL, \"customerid\" BIGINT NOT NULL, \"time\" TIMESTAMP WITH TIME ZONE NOT NULL, \"entries\" JSONB, PRIMARY KEY (\"id\",\"time\")) PARTITION BY RANGE (\"time\")", "fields" : [ { "name" : "id",