Skip to content

Commit c589160

Browse files
committed
upd
1 parent 7881482 commit c589160

16 files changed

Lines changed: 102 additions & 76 deletions

File tree

fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5259,7 +5259,7 @@ public DataType visitComplexDataType(ComplexDataTypeContext ctx) {
52595259
return ParserUtils.withOrigin(ctx, () -> {
52605260
switch (ctx.complex.getType()) {
52615261
case DorisParser.ARRAY:
5262-
return ArrayType.of(typedVisit(ctx.dataType(0)), true);
5262+
return ArrayType.of(typedVisit(ctx.dataType(0)));
52635263
case DorisParser.MAP:
52645264
return MapType.of(typedVisit(ctx.dataType(0)), typedVisit(ctx.dataType(1)));
52655265
case DorisParser.STRUCT:

fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,13 @@ public static List<Literal> getResultExpression(DataType type, PValues resultCon
629629

630630
private static Pair<DataType, Integer> convertToNereidsType(List<PTypeNode> typeNodes, int start) {
631631
PScalarType pScalarType = typeNodes.get(start).getScalarType();
632-
boolean containsNull = typeNodes.get(start).getContainsNull();
633632
TPrimitiveType tPrimitiveType = TPrimitiveType.findByValue(pScalarType.getType());
634633
DataType type;
635634
int parsedNodes;
636635
if (tPrimitiveType == TPrimitiveType.ARRAY) {
637636
Pair<DataType, Integer> itemType = convertToNereidsType(typeNodes, start + 1);
638-
type = ArrayType.of(itemType.key(), containsNull);
637+
// Array elements are always nullable
638+
type = ArrayType.of(itemType.key());
639639
parsedNodes = 1 + itemType.value();
640640
} else if (tPrimitiveType == TPrimitiveType.MAP) {
641641
Pair<DataType, Integer> keyType = convertToNereidsType(typeNodes, start + 1);

fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NestedColumnPruning.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ public DataType pruneCastType(DataTypeAccessTree origin, DataTypeAccessTree cast
503503
children.values().iterator().next().pruneCastType(
504504
origin.children.values().iterator().next(),
505505
cast.children.values().iterator().next()
506-
),
507-
((ArrayType) cast.type).containsNull()
506+
)
508507
);
509508
} else if (type instanceof MapType) {
510509
return MapType.of(
@@ -717,7 +716,7 @@ private DataType pruneDataType(DataType dataType, List<Pair<String, DataType>> n
717716
}
718717
return new StructType(newFields);
719718
} else if (dataType instanceof ArrayType) {
720-
return ArrayType.of(newChildrenTypes.get(0).second, ((ArrayType) dataType).containsNull());
719+
return ArrayType.of(newChildrenTypes.get(0).second);
721720
} else if (dataType instanceof MapType) {
722721
return MapType.of(newChildrenTypes.get(0).second, newChildrenTypes.get(1).second);
723722
} else {

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ArrayItemReference.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public List<String> getQualifier() {
7777

7878
@Override
7979
public boolean nullable() {
80-
return ((ArrayType) (this.children.get(0).getDataType())).containsNull();
80+
// Array elements are always nullable
81+
return true;
8182
}
8283

8384
@Override

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/AggCombinerFunctionBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ private AggregateFunction buildForEach(String nestedName, List<? extends Object>
9696
"foreach must be input array type: '" + nestedName);
9797
}
9898
DataType itemType = ((ArrayType) arrayType).getItemType();
99-
return new SlotReference("mocked", itemType, (((ArrayType) arrayType).containsNull()));
99+
// Array elements are always nullable
100+
return new SlotReference("mocked", itemType, true);
100101
}).collect(Collectors.toList());
101102
return (AggregateFunction) nestedBuilder.build(nestedName, forEachargs).first;
102103
}

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public static FunctionSignature ensureNestedNullableOfArray(FunctionSignature si
483483
return signature;
484484
}
485485
ArrayType arrayType = (ArrayType) signature.returnType;
486-
return signature.withReturnType(ArrayType.of(arrayType.getItemType(), true));
486+
return signature.withReturnType(ArrayType.of(arrayType.getItemType()));
487487
}
488488

489489
// for time type with precision(now are DateTimeV2Type and TimeV2Type),

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/combinator/ForEachCombinator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
119119

120120
@Override
121121
public DataType getDataType() {
122-
return ArrayType.of(nested.getDataType(), true);
122+
return ArrayType.of(nested.getDataType());
123123
}
124124

125125
@Override

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArrayMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public ArrayMap withChildren(List<Expression> children) {
6868
public DataType getDataType() {
6969
Preconditions.checkArgument(children.get(0) instanceof Lambda,
7070
"The first arg of array_map must be lambda");
71-
return ArrayType.of(((Lambda) children.get(0)).getRetType(), true);
71+
return ArrayType.of(((Lambda) children.get(0)).getRetType());
7272
}
7373

7474
@Override

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArraySort.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public DataType getDataType() {
9090
ArrayItemReference argRef = lambda.getLambdaArguments().get(0);
9191
Expression arrayExpr = argRef.getArrayExpression();
9292
ArrayType arrayType = (ArrayType) arrayExpr.getDataType();
93-
return ArrayType.of(arrayType.getItemType(), true);
93+
return ArrayType.of(arrayType.getItemType());
9494
} else if (children.get(0).getDataType() instanceof ArrayType) {
9595
Expression arrayExpr = children.get(0);
9696
ArrayType arrayType = (ArrayType) arrayExpr.getDataType();
97-
return ArrayType.of(arrayType.getItemType(), true);
97+
return ArrayType.of(arrayType.getItemType());
9898
} else {
9999
throw new AnalysisException("The first arg of array_sort must be lambda or array");
100100
}

fe/fe-core/src/main/java/org/apache/doris/nereids/types/ArrayType.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,43 @@
2424

2525
/**
2626
* Array type in Nereids.
27+
*
28+
* <p>Note: Array elements are always nullable in Doris. The NOT NULL constraint on array elements
29+
* (e.g., ARRAY&lt;INT NOT NULL&gt;) is not supported. This simplification aligns with the actual
30+
* behavior where both FE planning and BE execution always treat array elements as nullable.</p>
2731
*/
2832
public class ArrayType extends DataType implements ComplexDataType, NestedColumnPrunable {
2933

30-
public static final ArrayType SYSTEM_DEFAULT = new ArrayType(NullType.INSTANCE, true);
34+
public static final ArrayType SYSTEM_DEFAULT = new ArrayType(NullType.INSTANCE);
3135

3236
public static final int WIDTH = 64;
3337

3438
private final DataType itemType;
35-
private final boolean containsNull;
3639

37-
private ArrayType(DataType itemType, boolean containsNull) {
40+
private ArrayType(DataType itemType) {
3841
this.itemType = Objects.requireNonNull(itemType, "itemType can not be null");
39-
this.containsNull = containsNull;
4042
}
4143

4244
public static ArrayType of(DataType itemType) {
43-
return of(itemType, true);
44-
}
45-
46-
public static ArrayType of(DataType itemType, boolean containsNull) {
4745
if (itemType.equals(NullType.INSTANCE)) {
4846
return SYSTEM_DEFAULT;
4947
}
50-
return new ArrayType(itemType, containsNull);
48+
return new ArrayType(itemType);
5149
}
5250

5351
@Override
5452
public DataType conversion() {
55-
return new ArrayType(itemType.conversion(), containsNull);
53+
return new ArrayType(itemType.conversion());
5654
}
5755

5856
public DataType getItemType() {
5957
return itemType;
6058
}
6159

62-
public boolean containsNull() {
63-
return containsNull;
64-
}
65-
6660
@Override
6761
public Type toCatalogDataType() {
68-
return new org.apache.doris.catalog.ArrayType(itemType.toCatalogDataType(), containsNull);
62+
// Catalog ArrayType defaults containsNull to true via single-arg constructor
63+
return new org.apache.doris.catalog.ArrayType(itemType.toCatalogDataType());
6964
}
7065

7166
@Override
@@ -85,8 +80,7 @@ public boolean equals(Object o) {
8580
return false;
8681
}
8782
ArrayType arrayType = (ArrayType) o;
88-
return Objects.equals(itemType, arrayType.itemType)
89-
&& Objects.equals(containsNull, arrayType.containsNull);
83+
return Objects.equals(itemType, arrayType.itemType);
9084
}
9185

9286
@Override

0 commit comments

Comments
 (0)