[Improve](complex-type) Support Count(complexType) (#17868)

Support count function for ARRAY/MAP/STRUCT type
This commit is contained in:
amory
2023-03-30 15:43:32 +08:00
committed by GitHub
parent e3bd812887
commit ea41d94582
27 changed files with 175 additions and 86 deletions

View File

@ -175,11 +175,14 @@ public class StructType extends Type {
}
StructType other = (StructType) t;
if (fields.size() != other.getFields().size()) {
// Temp to make NullPredict from fe send to be
return other.getFields().size() == 1 && Objects.equals(other.getFields().get(0).name, "null_pred");
// Temp to make NullPredict from fe send to be
if (other.getFields().size() == 1 && Objects.equals(other.getFields().get(0).name,
Type.GENERIC_STRUCT.getFields().get(0).name)) {
return true;
}
if (fields.size() != other.getFields().size()) {
return false;
}
for (int i = 0; i < fields.size(); i++) {
if (!fields.get(i).matchesField(((StructType) t).getFields().get(i))) {
return false;

View File

@ -107,6 +107,8 @@ public abstract class Type {
public static final ScalarType ALL = new ScalarType(PrimitiveType.ALL);
public static final MapType MAP = new MapType();
public static final ArrayType ARRAY = ArrayType.create();
public static final StructType GENERIC_STRUCT = new StructType(Lists.newArrayList(
new StructField("generic_struct", new ScalarType(PrimitiveType.NULL_TYPE))));
public static final StructType STRUCT = new StructType();
public static final VariantType VARIANT = new VariantType();