[improvement](type) modify the inner type display of the Array/Map/Struct type (#24459)
In the old code, when using desc command to view the table schema It will display as follows ``` ARRAY<TINYINT(4)> ARRAY<SMALLINT(6)> ARRAY<INT(11)> ARRAY<BIGINT(20)> ARRAY<LARGEINT(40)> ``` However, for normal integer type displays, the width is not displayed So, I changed it to the following ``` ARRAY<TINYINT> ARRAY<SMALLINT> ARRAY<INT> ARRAY<BIGINT> ARRAY<LARGEINT> ```
This commit is contained in:
@ -203,7 +203,7 @@ public class ArrayType extends Type {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toSql(0).toUpperCase();
|
||||
return String.format("ARRAY<%s>", itemType.toString()).toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -174,7 +174,8 @@ public class MapType extends Type {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toSql(0).toUpperCase();
|
||||
return String.format("MAP<%s,%s>",
|
||||
keyType.toString(), valueType.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -158,4 +158,16 @@ public class StructField {
|
||||
return otherStructField.name.equals(name) && otherStructField.type.equals(type)
|
||||
&& otherStructField.containsNull == containsNull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(name);
|
||||
if (type != null) {
|
||||
sb.append(":").append(type);
|
||||
}
|
||||
if (StringUtils.isNotBlank(comment)) {
|
||||
sb.append(String.format(" COMMENT '%s'", comment));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +303,11 @@ public class StructType extends Type {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toSql(0);
|
||||
ArrayList<String> fieldsSql = Lists.newArrayList();
|
||||
for (StructField f : fields) {
|
||||
fieldsSql.add(f.toString());
|
||||
}
|
||||
return String.format("STRUCT<%s>", Joiner.on(",").join(fieldsSql));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -21,9 +21,9 @@ value2 INT Yes false \N SUM
|
||||
-- !sql --
|
||||
k1 INT Yes true \N
|
||||
value1 INT Yes false \N NONE
|
||||
value2 ARRAY<INT(11)> Yes false [] NONE
|
||||
value3 ARRAY<INT(11)> Yes false \N NONE
|
||||
value4 ARRAY<INT(11)> No false [] NONE
|
||||
value2 ARRAY<INT> Yes false [] NONE
|
||||
value3 ARRAY<INT> Yes false \N NONE
|
||||
value4 ARRAY<INT> No false [] NONE
|
||||
|
||||
-- !sql --
|
||||
1 2 [] \N []
|
||||
|
||||
Reference in New Issue
Block a user