[enhancement](sequence col) add session variable to skip sequence column check while INSERT INTO (#41655) (#41720)
cp #41655
This commit is contained in:
@ -500,7 +500,8 @@ public class NativeInsertStmt extends InsertStmt {
|
||||
}
|
||||
|
||||
if (!haveInputSeqCol && !isPartialUpdate && !isFromDeleteOrUpdateStmt
|
||||
&& !analyzer.getContext().getSessionVariable().isEnableUniqueKeyPartialUpdate()) {
|
||||
&& !analyzer.getContext().getSessionVariable().isEnableUniqueKeyPartialUpdate()
|
||||
&& analyzer.getContext().getSessionVariable().isRequireSequenceInInsert()) {
|
||||
if (!seqColInTable.isPresent() || seqColInTable.get().getDefaultValue() == null
|
||||
|| !seqColInTable.get().getDefaultValue()
|
||||
.equalsIgnoreCase(DefaultValue.CURRENT_TIMESTAMP)) {
|
||||
|
||||
@ -74,6 +74,7 @@ import org.apache.doris.nereids.types.coercion.CharacterType;
|
||||
import org.apache.doris.nereids.util.ExpressionUtils;
|
||||
import org.apache.doris.nereids.util.RelationUtil;
|
||||
import org.apache.doris.nereids.util.TypeCoercionUtils;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -198,9 +199,12 @@ public class BindSink implements AnalysisRuleFactory {
|
||||
// including the following cases:
|
||||
// 1. it's a load job with `partial_columns=true`
|
||||
// 2. UPDATE and DELETE, planner will automatically add these hidden columns
|
||||
// 3. session value `require_sequence_in_insert` is false
|
||||
if (!haveInputSeqCol && !isPartialUpdate && (
|
||||
boundSink.getDmlCommandType() != DMLCommandType.UPDATE
|
||||
&& boundSink.getDmlCommandType() != DMLCommandType.DELETE)) {
|
||||
&& boundSink.getDmlCommandType() != DMLCommandType.DELETE) && (
|
||||
boundSink.getDmlCommandType() != DMLCommandType.INSERT
|
||||
|| ConnectContext.get().getSessionVariable().isRequireSequenceInInsert())) {
|
||||
if (!seqColInTable.isPresent() || seqColInTable.get().getDefaultValue() == null
|
||||
|| !seqColInTable.get().getDefaultValue()
|
||||
.equalsIgnoreCase(DefaultValue.CURRENT_TIMESTAMP)) {
|
||||
|
||||
@ -635,6 +635,7 @@ public class SessionVariable implements Serializable, Writable {
|
||||
"enable_adaptive_pipeline_task_serial_read_on_limit";
|
||||
public static final String ADAPTIVE_PIPELINE_TASK_SERIAL_READ_ON_LIMIT =
|
||||
"adaptive_pipeline_task_serial_read_on_limit";
|
||||
public static final String REQUIRE_SEQUENCE_IN_INSERT = "require_sequence_in_insert";
|
||||
|
||||
/**
|
||||
* If set false, user couldn't submit analyze SQL and FE won't allocate any related resources.
|
||||
@ -2074,6 +2075,13 @@ public class SessionVariable implements Serializable, Writable {
|
||||
})
|
||||
public int adaptivePipelineTaskSerialReadOnLimit = 10000;
|
||||
|
||||
@VariableMgr.VarAttr(name = REQUIRE_SEQUENCE_IN_INSERT, needForward = true, description = {
|
||||
"该变量用于控制,使用了sequence列的unique key表,insert into操作是否要求必须提供每一行的sequence列的值",
|
||||
"This variable controls whether the INSERT INTO operation on unique key tables with a sequence"
|
||||
+ " column requires a sequence column to be provided for each row"
|
||||
})
|
||||
public boolean requireSequenceInInsert = true;
|
||||
|
||||
public void setEnableEsParallelScroll(boolean enableESParallelScroll) {
|
||||
this.enableESParallelScroll = enableESParallelScroll;
|
||||
}
|
||||
@ -3443,6 +3451,14 @@ public class SessionVariable implements Serializable, Writable {
|
||||
this.loadStreamPerNode = loadStreamPerNode;
|
||||
}
|
||||
|
||||
public void setRequireSequenceInInsert(boolean value) {
|
||||
this.requireSequenceInInsert = value;
|
||||
}
|
||||
|
||||
public boolean isRequireSequenceInInsert() {
|
||||
return this.requireSequenceInInsert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize to thrift object.
|
||||
* Used for rest api.
|
||||
|
||||
Reference in New Issue
Block a user