[opt](Nereids) let DataType toSql same with legacy planner (#26576)

This commit is contained in:
morrySnow
2023-11-08 19:34:32 +08:00
committed by GitHub
parent ec87401581
commit 223be6947c
6 changed files with 11 additions and 10 deletions

View File

@ -104,7 +104,7 @@ public class MapType extends DataType {
@Override
public String toSql() {
return "MAP<" + keyType.toSql() + ", " + valueType.toSql() + ">";
return "MAP<" + keyType.toSql() + "," + valueType.toSql() + ">";
}
@Override

View File

@ -43,7 +43,7 @@ public class StringType extends CharacterType {
@Override
public String simpleString() {
return "string";
return "text";
}
@Override

View File

@ -19,6 +19,7 @@ package org.apache.doris.nereids.types;
import org.apache.doris.nereids.util.Utils;
import java.util.Locale;
import java.util.Objects;
/**
@ -38,7 +39,7 @@ public class StructField {
* @param nullable Indicates if values of this field can be `null` values
*/
public StructField(String name, DataType dataType, boolean nullable, String comment) {
this.name = Objects.requireNonNull(name, "name should not be null");
this.name = Objects.requireNonNull(name, "name should not be null").toLowerCase(Locale.ROOT);
this.dataType = Objects.requireNonNull(dataType, "dataType should not be null");
this.nullable = nullable;
this.comment = Objects.requireNonNull(comment, "comment should not be null");
@ -82,7 +83,7 @@ public class StructField {
public String toSql() {
return name + ":" + dataType.toSql()
+ (nullable ? " " : " NOT NULL")
+ (nullable ? "" : " NOT NULL")
+ (comment.isEmpty() ? "" : " COMMENT " + comment);
}

View File

@ -119,11 +119,11 @@ public class StructType extends DataType {
@Override
public String toSql() {
return "STRUCT<" + fields.stream().map(StructField::toSql).collect(Collectors.joining(", ")) + ">";
return "STRUCT<" + fields.stream().map(StructField::toSql).collect(Collectors.joining(",")) + ">";
}
@Override
public String toString() {
return "STRUCT<" + fields.stream().map(StructField::toString).collect(Collectors.joining(", ")) + ">";
return "STRUCT<" + fields.stream().map(StructField::toString).collect(Collectors.joining(",")) + ">";
}
}