[Bug](materialized-view) fix mv not match because cast and alias name (#23580)

fix mv not match because cast and alias name
This commit is contained in:
Pxl
2023-09-04 12:46:33 +08:00
committed by GitHub
parent 0179e5c2ba
commit bb3fadc5d3
91 changed files with 865 additions and 634 deletions

View File

@ -575,7 +575,7 @@ public class ScalarType extends Type {
break;
case VARCHAR:
if (isWildcardVarchar()) {
stringBuilder.append("varchar");
stringBuilder.append("varchar(*)");
} else if (Strings.isNullOrEmpty(lenStr)) {
stringBuilder.append("varchar").append("(").append(len).append(")");
} else {
@ -678,7 +678,7 @@ public class ScalarType extends Type {
case HLL:
case STRING:
case JSONB: {
scalarType.setLen(len);
scalarType.setLen(getLength());
break;
}
case DECIMALV2:
@ -730,6 +730,20 @@ public class ScalarType extends Type {
@Override
public int getLength() {
if (len == -1) {
if (type == PrimitiveType.CHAR) {
return MAX_CHAR_LENGTH;
} else if (type == PrimitiveType.STRING) {
return MAX_STRING_LENGTH;
} else {
return MAX_VARCHAR_LENGTH;
}
}
return len;
}
@Override
public int getRawLength() {
return len;
}
@ -738,15 +752,7 @@ public class ScalarType extends Type {
}
public void setMaxLength() {
if (type == PrimitiveType.CHAR) {
this.len = MAX_CHAR_LENGTH;
}
if (type == PrimitiveType.VARCHAR) {
this.len = MAX_VARCHAR_LENGTH;
}
if (type == PrimitiveType.STRING) {
this.len = MAX_STRING_LENGTH;
}
this.len = -1;
}
public boolean isLengthSet() {
@ -782,12 +788,12 @@ public class ScalarType extends Type {
@Override
public boolean isWildcardVarchar() {
return (type == PrimitiveType.VARCHAR || type == PrimitiveType.HLL) && len == -1;
return (type == PrimitiveType.VARCHAR || type == PrimitiveType.HLL) && (len == -1 || len == MAX_VARCHAR_LENGTH);
}
@Override
public boolean isWildcardChar() {
return type == PrimitiveType.CHAR && len == -1;
return type == PrimitiveType.CHAR && (len == -1 || len == MAX_CHAR_LENGTH);
}
@Override
@ -843,11 +849,9 @@ public class ScalarType extends Type {
}
ScalarType scalarType = (ScalarType) t;
if (type == PrimitiveType.VARCHAR && scalarType.isWildcardVarchar()) {
Preconditions.checkState(!isWildcardVarchar());
return true;
}
if (type == PrimitiveType.CHAR && scalarType.isWildcardChar()) {
Preconditions.checkState(!isWildcardChar());
return true;
}
if (type.isStringType() && scalarType.isStringType()) {

View File

@ -637,6 +637,10 @@ public abstract class Type {
return -1;
}
public int getRawLength() {
return -1;
}
/**
* Indicates whether we support partitioning tables on columns of this type.
*/