Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.doris.analysis.StringLiteral;
import org.apache.doris.catalog.AggregateType;
import org.apache.doris.catalog.PartitionType;
import org.apache.doris.common.DdlException;
import org.apache.doris.nereids.analyzer.UnboundFunction;
import org.apache.doris.nereids.analyzer.UnboundSlot;
import org.apache.doris.nereids.exceptions.AnalysisException;
Expand Down Expand Up @@ -269,6 +270,14 @@ public PartitionDesc convertToPartitionDesc(boolean isExternal) {

try {
ArrayList<Expr> exprs = convertToLegacyAutoPartitionExprs(partitionList);

// only auto partition support partition expr
if (!isAutoPartition) {
if (exprs.stream().anyMatch(expr -> expr instanceof FunctionCallExpr)) {
throw new DdlException("Non-auto partition table not support partition expr!");
}
}

// here we have already extracted identifierPartitionColumns
if (partitionType.equals(PartitionType.RANGE.name())) {
if (isAutoPartition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,18 @@ suite("test_auto_partition_behavior") {
sql """ insert into test_change values ("20001212"); """
part_result = sql " show tablets from test_change "
assertEquals(part_result.size, 52 * replicaNum)

test {
sql """
CREATE TABLE not_auto_expr (
`TIME_STAMP` date NOT NULL
)
partition by range (date_trunc(`TIME_STAMP`, 'day'))()
DISTRIBUTED BY HASH(`TIME_STAMP`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
exception "Non-auto partition table not support partition expr!"
}
}