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 @@ -108,6 +108,10 @@ public void analyze(List<ColumnDef> columnDefs, Map<String, String> otherPropert
throw new AnalysisException("String Type should not be used in partition column["
+ columnDef.getName() + "].");
}
if (columnDef.getType().isComplexType()) {
throw new AnalysisException("Complex type column can't be partition column: "
+ columnDef.getType().toString());
}
if (!ConnectContext.get().getSessionVariable().isAllowPartitionColumnNullable()
&& columnDef.isAllowNull()) {
throw new AnalysisException("The partition column must be NOT NULL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public PartitionInfo toPartitionInfo(List<Column> schema, Map<String, Long> part
boolean find = false;
for (Column column : schema) {
if (column.getName().equalsIgnoreCase(colName)) {
if (column.getType().isComplexType()) {
throw new DdlException("Complex type column can't be partition column: "
+ column.getType().toString());
}
try {
RangePartitionInfo.checkPartitionColumn(column);
} catch (AnalysisException e) {
Expand All @@ -94,10 +98,6 @@ public PartitionInfo toPartitionInfo(List<Column> schema, Map<String, Long> part
find = true;
break;
}
if (column.getType().isComplexType()) {
throw new DdlException("Complex type column can't be partition column: "
+ column.getType().toString());
}
}
if (!find) {
throw new DdlException("Partition column[" + colName + "] does not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,5 +644,46 @@ public void testCreateTableWithArrayType() throws Exception {
+ ") distributed by hash(k1) buckets 1\n"
+ "properties(\"replication_num\" = \"1\");");
});

ExceptionChecker.expectThrowsNoException(() -> {
createTable("create table test.test_array( \n"
+ "task_insert_time BIGINT NOT NULL DEFAULT \"0\" COMMENT \"\" , \n"
+ "task_project ARRAY<VARCHAR(64)> DEFAULT NULL COMMENT \"\" ,\n"
+ "route_key DATEV2 NOT NULL COMMENT \"range分区键\"\n"
+ ") \n"
+ "DUPLICATE KEY(`task_insert_time`) \n"
+ " COMMENT \"\"\n"
+ "PARTITION BY RANGE(route_key) \n"
+ "(PARTITION `p202209` VALUES LESS THAN (\"2022-10-01\"),\n"
+ "PARTITION `p202210` VALUES LESS THAN (\"2022-11-01\"),\n"
+ "PARTITION `p202211` VALUES LESS THAN (\"2022-12-01\")) \n"
+ "DISTRIBUTED BY HASH(`task_insert_time` ) BUCKETS 32 \n"
+ "PROPERTIES\n"
+ "(\n"
+ " \"replication_num\" = \"1\", \n"
+ " \"light_schema_change\" = \"true\" \n"
+ ");");
});

ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "Complex type column can't be partition column",
() -> {
createTable("create table test.test_array2( \n"
+ "task_insert_time BIGINT NOT NULL DEFAULT \"0\" COMMENT \"\" , \n"
+ "task_project ARRAY<VARCHAR(64)> DEFAULT NULL COMMENT \"\" ,\n"
+ "route_key DATEV2 NOT NULL COMMENT \"range分区键\"\n"
+ ") \n"
+ "DUPLICATE KEY(`task_insert_time`) \n"
+ " COMMENT \"\"\n"
+ "PARTITION BY RANGE(task_project) \n"
+ "(PARTITION `p202209` VALUES LESS THAN (\"2022-10-01\"),\n"
+ "PARTITION `p202210` VALUES LESS THAN (\"2022-11-01\"),\n"
+ "PARTITION `p202211` VALUES LESS THAN (\"2022-12-01\")) \n"
+ "DISTRIBUTED BY HASH(`task_insert_time` ) BUCKETS 32 \n"
+ "PROPERTIES\n"
+ "(\n"
+ " \"replication_num\" = \"1\", \n"
+ " \"light_schema_change\" = \"true\" \n"
+ ");");
});
}
}