[Repair] Add an option whether to allow the partition column to be NULL (#5013)
This commit is contained in:
@ -29,6 +29,7 @@ import org.apache.doris.common.DdlException;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -78,6 +79,10 @@ public class RangePartitionDesc extends PartitionDesc {
|
||||
if (columnDef.getType().isFloatingPointType()) {
|
||||
throw new AnalysisException("Floating point type column can not be partition column");
|
||||
}
|
||||
if (!ConnectContext.get().getSessionVariable().isAllowPartitionColumnNullable()
|
||||
&& columnDef.isAllowNull()) {
|
||||
throw new AnalysisException("The partition column must be NOT NULL");
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@ -157,6 +162,11 @@ public class RangePartitionDesc extends PartitionDesc {
|
||||
throw new DdlException("Floating point type column can not be partition column");
|
||||
}
|
||||
|
||||
if (!ConnectContext.get().getSessionVariable().isAllowPartitionColumnNullable()
|
||||
&& column.isAllowNull()) {
|
||||
throw new DdlException("The partition column must be NOT NULL");
|
||||
}
|
||||
|
||||
try {
|
||||
RangePartitionInfo.checkRangeColumnType(column);
|
||||
} catch (AnalysisException e) {
|
||||
|
||||
@ -108,6 +108,9 @@ public class SessionVariable implements Serializable, Writable {
|
||||
public static final String MAX_SCAN_KEY_NUM = "max_scan_key_num";
|
||||
public static final String MAX_PUSHDOWN_CONDITIONS_PER_COLUMN = "max_pushdown_conditions_per_column";
|
||||
|
||||
// when true, the partition column must be set to NOT NULL.
|
||||
public static final String ALLOW_PARTITION_COLUMN_NULLABLE = "allow_partition_column_nullable";
|
||||
|
||||
// max memory used on every backend.
|
||||
@VariableMgr.VarAttr(name = EXEC_MEM_LIMIT)
|
||||
public long maxExecMemByte = 2147483648L;
|
||||
@ -270,6 +273,9 @@ public class SessionVariable implements Serializable, Writable {
|
||||
@VariableMgr.VarAttr(name = SHOW_HIDDEN_COLUMNS, flag = VariableMgr.SESSION_ONLY)
|
||||
private boolean showHiddenColumns = false;
|
||||
|
||||
@VariableMgr.VarAttr(name = ALLOW_PARTITION_COLUMN_NULLABLE)
|
||||
private boolean allowPartitionColumnNullable = true;
|
||||
|
||||
public long getMaxExecMemByte() {
|
||||
return maxExecMemByte;
|
||||
}
|
||||
@ -528,6 +534,8 @@ public class SessionVariable implements Serializable, Writable {
|
||||
this.showHiddenColumns = showHiddenColumns;
|
||||
}
|
||||
|
||||
public boolean isAllowPartitionColumnNullable() { return allowPartitionColumnNullable; }
|
||||
|
||||
|
||||
// Serialize to thrift object
|
||||
// used for rest api
|
||||
|
||||
Reference in New Issue
Block a user