[branch-2.1] Picks "[Fix](partial update) Fix __DORIS_SEQUENCE_COL__ is not set for newly inserted rows in partial update #40272" (#40964)
picks https://github.com/apache/doris/pull/40272
This commit is contained in:
@ -1024,4 +1024,10 @@ public class Column implements Writable, GsonPostProcessable {
|
||||
return getName().startsWith(CreateMaterializedViewStmt.MATERIALIZED_VIEW_NAME_PREFIX)
|
||||
|| getName().startsWith(CreateMaterializedViewStmt.MATERIALIZED_VIEW_AGGREGATE_NAME_PREFIX);
|
||||
}
|
||||
|
||||
public void setDefaultValueInfo(Column refColumn) {
|
||||
this.defaultValue = refColumn.defaultValue;
|
||||
this.defaultValueExprDef = refColumn.defaultValueExprDef;
|
||||
this.realDefaultValue = refColumn.realDefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1207,7 +1207,7 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
|
||||
getOrCreatTableProperty().setSequenceMapCol(colName);
|
||||
}
|
||||
|
||||
public void setSequenceInfo(Type type) {
|
||||
public void setSequenceInfo(Type type, Column refColumn) {
|
||||
this.hasSequenceCol = true;
|
||||
this.sequenceType = type;
|
||||
|
||||
@ -1221,6 +1221,9 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
|
||||
// unique key table
|
||||
sequenceCol = ColumnDef.newSequenceColumnDef(type, AggregateType.REPLACE).toColumn();
|
||||
}
|
||||
if (refColumn != null) {
|
||||
sequenceCol.setDefaultValueInfo(refColumn);
|
||||
}
|
||||
// add sequence column at last
|
||||
fullSchema.add(sequenceCol);
|
||||
nameToColumn.put(Column.SEQUENCE_COL, sequenceCol);
|
||||
@ -1717,6 +1720,18 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
|
||||
defaultDistributionInfo.markAutoBucket();
|
||||
}
|
||||
|
||||
if (isUniqKeyMergeOnWrite() && getSequenceMapCol() != null) {
|
||||
// set the hidden sequence column's default value the same with
|
||||
// the sequence map column's for partial update
|
||||
String seqMapColName = getSequenceMapCol();
|
||||
Column seqMapCol = getBaseSchema().stream().filter(col -> col.getName().equalsIgnoreCase(seqMapColName))
|
||||
.findFirst().orElse(null);
|
||||
Column hiddenSeqCol = getSequenceCol();
|
||||
if (seqMapCol != null && hiddenSeqCol != null) {
|
||||
hiddenSeqCol.setDefaultValueInfo(seqMapCol);
|
||||
}
|
||||
}
|
||||
|
||||
// temp partitions
|
||||
tempPartitions = TempPartitions.read(in);
|
||||
RangePartitionInfo tempRangeInfo = tempPartitions.getPartitionInfo();
|
||||
|
||||
@ -2759,7 +2759,7 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
throw new DdlException("Sequence type only support integer types and date types");
|
||||
}
|
||||
olapTable.setSequenceMapCol(col.getName());
|
||||
olapTable.setSequenceInfo(col.getType());
|
||||
olapTable.setSequenceInfo(col.getType(), col);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DdlException(e.getMessage());
|
||||
@ -2773,7 +2773,7 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
throw new DdlException("The sequence_col and sequence_type cannot be set at the same time");
|
||||
}
|
||||
if (sequenceColType != null) {
|
||||
olapTable.setSequenceInfo(sequenceColType);
|
||||
olapTable.setSequenceInfo(sequenceColType, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DdlException(e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user