[fix](Nereids) support string cast to complex type (#25154)

This commit is contained in:
morrySnow
2023-10-10 10:26:33 +08:00
committed by GitHub
parent 3a29bb4bc5
commit 59dee6b235
3 changed files with 17 additions and 2 deletions

View File

@ -29,6 +29,7 @@ import org.apache.doris.nereids.types.MapType;
import org.apache.doris.nereids.types.StructField;
import org.apache.doris.nereids.types.StructType;
import org.apache.doris.nereids.types.coercion.CharacterType;
import org.apache.doris.nereids.types.coercion.PrimitiveType;
import java.util.List;
@ -57,6 +58,9 @@ public class CheckCast extends AbstractExpressionRewriteRule {
if (originalType.equals(targetType)) {
return true;
}
if (originalType instanceof CharacterType && !(targetType instanceof PrimitiveType)) {
return true;
}
if (originalType instanceof ArrayType && targetType instanceof ArrayType) {
return check(((ArrayType) originalType).getItemType(), ((ArrayType) targetType).getItemType());
} else if (originalType instanceof MapType && targetType instanceof MapType) {
@ -77,8 +81,6 @@ public class CheckCast extends AbstractExpressionRewriteRule {
}
}
return true;
} else if (originalType instanceof CharacterType && targetType instanceof StructType) {
return true;
} else if (originalType instanceof JsonType || targetType instanceof JsonType) {
return true;
} else {