Skip to content

Commit

Permalink
Merge branch 'feature_sc_optimize' of github.com:Lchangliang/incubato…
Browse files Browse the repository at this point in the history
…r-doris into feature_sc_optimize
  • Loading branch information
Lchangliang committed Jun 30, 2022
2 parents 9169123 + ebd6778 commit 3085c74
Show file tree
Hide file tree
Showing 13 changed files with 520 additions and 571 deletions.
273 changes: 137 additions & 136 deletions fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ public boolean layoutEquals(SlotDescriptor other) {
public TSlotDescriptor toThrift() {

TSlotDescriptor tSlotDescriptor = new TSlotDescriptor(id.asInt(), parent.getId().asInt(),
(originType != null ? originType.toThrift() : type.toThrift()), -1, byteOffset,
nullIndicatorByte, nullIndicatorBit, ((column != null) ? column.getName() : ""),
slotIdx, isMaterialized);
(originType != null ? originType.toThrift() : type.toThrift()), -1, byteOffset, nullIndicatorByte,
nullIndicatorBit, ((column != null) ? column.getName() : ""), slotIdx, isMaterialized);

if (column != null) {
LOG.debug("column name:{}, column unique id:{}", column.getName(), column.getUniqueId());
Expand All @@ -300,12 +299,10 @@ public String debugString() {
String colStr = (column == null ? "null" : column.getName());
String typeStr = (type == null ? "null" : type.toString());
String parentTupleId = (parent == null) ? "null" : parent.getId().toString();
return MoreObjects.toStringHelper(this).add("id", id.asInt()).add("parent", parentTupleId)
.add("col", colStr).add("type", typeStr).add("materialized", isMaterialized)
.add("byteSize", byteSize).add("byteOffset", byteOffset)
.add("nullIndicatorByte", nullIndicatorByte)
.add("nullIndicatorBit", nullIndicatorBit)
.add("slotIdx", slotIdx).toString();
return MoreObjects.toStringHelper(this).add("id", id.asInt()).add("parent", parentTupleId).add("col", colStr)
.add("type", typeStr).add("materialized", isMaterialized).add("byteSize", byteSize)
.add("byteOffset", byteOffset).add("nullIndicatorByte", nullIndicatorByte)
.add("nullIndicatorBit", nullIndicatorBit).add("slotIdx", slotIdx).toString();
}

@Override
Expand All @@ -318,10 +315,8 @@ public String getExplainString(String prefix) {
String colStr = (column == null ? "null" : column.getName());
String typeStr = (type == null ? "null" : type.toString());
String parentTupleId = (parent == null) ? "null" : parent.getId().toString();
builder.append(prefix).append("SlotDescriptor{")
.append("id=").append(id)
.append(", col=").append(colStr)
.append(", type=").append(typeStr).append("}\n");
builder.append(prefix).append("SlotDescriptor{").append("id=").append(id).append(", col=").append(colStr)
.append(", type=").append(typeStr).append("}\n");

prefix += " ";
builder.append(prefix).append("parent=").append(parentTupleId).append("\n");
Expand Down
260 changes: 126 additions & 134 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java

Large diffs are not rendered by default.

31 changes: 17 additions & 14 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,19 @@ public Column(String name, Type type) {
}

public Column(String name, Type type, boolean isKey, AggregateType aggregateType, String defaultValue,
String comment) {
String comment) {
this(name, type, isKey, aggregateType, false, defaultValue, comment);
}

public Column(String name, Type type, boolean isKey, AggregateType aggregateType, boolean isAllowNull,
String defaultValue, String comment) {
this(name, type, isKey, aggregateType, isAllowNull, defaultValue, comment, true, null, COLUMN_UNIQUE_ID_INIT_VALUE);
String defaultValue, String comment) {
this(name, type, isKey, aggregateType, isAllowNull, defaultValue, comment, true, null,
COLUMN_UNIQUE_ID_INIT_VALUE);
}

public Column(String name, Type type, boolean isKey, AggregateType aggregateType, boolean isAllowNull,
String defaultValue, String comment, boolean visible, DefaultValueExprDef defaultValueExprDef, int colUniqueId) {
String defaultValue, String comment, boolean visible, DefaultValueExprDef defaultValueExprDef,
int colUniqueId) {
this.name = name;
if (this.name == null) {
this.name = "";
Expand Down Expand Up @@ -428,8 +430,8 @@ public void checkSchemaChangeAllowed(Column other) throws DdlException {
Integer lSize = type.getColumnStringRepSize();
Integer rSize = other.type.getColumnStringRepSize();
if (rSize < lSize) {
throw new DdlException("Can not change from wider type " + type.toSql()
+ " to narrower type " + other.type.toSql());
throw new DdlException(
"Can not change from wider type " + type.toSql() + " to narrower type " + other.type.toSql());
}
}

Expand All @@ -451,9 +453,9 @@ public void checkSchemaChangeAllowed(Column other) throws DdlException {
}
}

if ((getDataType() == PrimitiveType.VARCHAR && other.getDataType() == PrimitiveType.VARCHAR)
|| (getDataType() == PrimitiveType.CHAR && other.getDataType() == PrimitiveType.VARCHAR)
|| (getDataType() == PrimitiveType.CHAR && other.getDataType() == PrimitiveType.CHAR)) {
if ((getDataType() == PrimitiveType.VARCHAR && other.getDataType() == PrimitiveType.VARCHAR) || (
getDataType() == PrimitiveType.CHAR && other.getDataType() == PrimitiveType.VARCHAR) || (
getDataType() == PrimitiveType.CHAR && other.getDataType() == PrimitiveType.CHAR)) {
if (getStrLen() > other.getStrLen()) {
throw new DdlException("Cannot shorten string length");
}
Expand Down Expand Up @@ -532,8 +534,8 @@ public String toSql(boolean isUniqueTable) {
sb.append("`").append(name).append("` ");
String typeStr = type.toSql();
sb.append(typeStr).append(" ");
if (aggregationType != null && aggregationType != AggregateType.NONE
&& !isUniqueTable && !isAggregationTypeImplicit) {
if (aggregationType != null && aggregationType != AggregateType.NONE && !isUniqueTable
&& !isAggregationTypeImplicit) {
sb.append(aggregationType.name()).append(" ");
}
if (isAllowNull) {
Expand All @@ -556,9 +558,8 @@ public String toString() {

@Override
public int hashCode() {
return Objects.hash(name, getDataType(), aggregationType, isAggregationTypeImplicit,
isKey, isAllowNull, getDefaultValue(), getStrLen(), getPrecision(), getScale(),
comment, visible, children);
return Objects.hash(name, getDataType(), aggregationType, isAggregationTypeImplicit, isKey, isAllowNull,
getDefaultValue(), getStrLen(), getPrecision(), getScale(), comment, visible, children);
}

@Override
Expand Down Expand Up @@ -695,9 +696,11 @@ public String getSignatureString(Map<PrimitiveType, String> typeStringMap) {
sb.append(defaultValue == null ? "" : defaultValue);
return sb.toString();
}

public void setUniqueId(int colUniqueId) {
this.uniqueId = colUniqueId;
}

public int getUniqueId() {
return this.uniqueId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class Table extends MetaObject implements Writable, TableIf {
* Schema change (c3 to bigint)
* When OlapTable is changing schema, the fullSchema is (c1 int, c2 int, c3 int, SHADOW_NAME_PRFIX_c3 bigint)
* The fullSchema of OlapTable is mainly used by Scanner of Load job.
*
* <p>
* If you want to get the mv columns, you should call getIndexToSchema in Subclass OlapTable.
*/
protected List<Column> fullSchema;
Expand Down
Loading

0 comments on commit 3085c74

Please sign in to comment.