Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion be/src/vec/functions/array/function_array_aggregation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ struct ArrayAggregateImpl {
const DataTypeArray* data_type_array =
static_cast<const DataTypeArray*>(remove_nullable(arguments[0]).get());
auto function = Function::create(data_type_array->get_nested_type());
return function->get_return_type();
if (function) {
return function->get_return_type();
} else {
throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
"Unexpected type {} for aggregation {}",
data_type_array->get_nested_type()->get_name(), operation);
}
}

static Status execute(Block& block, const ColumnNumbers& arguments, size_t result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.doris.nereids.trees.expressions.functions.scalar;

import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
Expand Down Expand Up @@ -50,6 +51,14 @@ public ArrayMax(Expression arg) {
super("array_max", arg);
}

@Override
public void checkLegalityBeforeTypeCoercion() {
DataType argType = child().getDataType();
if (((ArrayType) argType).getItemType().isComplexType()) {
throw new AnalysisException("array_max does not support complex types: " + toSql());
}
}

@Override
public DataType getDataType() {
return ((ArrayType) (child().getDataType())).getItemType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.doris.nereids.trees.expressions.functions.scalar;

import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
Expand Down Expand Up @@ -50,6 +51,14 @@ public ArrayMin(Expression arg) {
super("array_min", arg);
}

@Override
public void checkLegalityBeforeTypeCoercion() {
DataType argType = child().getDataType();
if (((ArrayType) argType).getItemType().isComplexType()) {
throw new AnalysisException("array_min does not support complex types: " + toSql());
}
}

@Override
public DataType getDataType() {
return ((ArrayType) (child().getDataType())).getItemType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
package org.apache.doris.nereids.trees.expressions.functions.scalar;

import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.ArrayType;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.AnyDataType;

import com.google.common.base.Preconditions;
Expand All @@ -48,6 +50,14 @@ public ArrayReverseSort(Expression arg) {
super("array_reverse_sort", arg);
}

@Override
public void checkLegalityBeforeTypeCoercion() {
DataType argType = child().getDataType();
if (((ArrayType) argType).getItemType().isComplexType()) {
throw new AnalysisException("array_reverse_sort does not support complex types: " + toSql());
}
}

/**
* withChildren.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
package org.apache.doris.nereids.trees.expressions.functions.scalar;

import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.ArrayType;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.AnyDataType;

import com.google.common.base.Preconditions;
Expand All @@ -48,6 +50,14 @@ public ArraySort(Expression arg) {
super("array_sort", arg);
}

@Override
public void checkLegalityBeforeTypeCoercion() {
DataType argType = child().getDataType();
if (((ArrayType) argType).getItemType().isComplexType()) {
throw new AnalysisException("array_sort does not support complex types: " + toSql());
}
}

/**
* withChildren.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ suite("nereids_scalar_fn_Array") {
}
}

// with array empty
sql """ set enable_fold_constant_by_be=true; """
qt_array_empty_fe """select array()"""

// array_map with string is can be succeed
Expand All @@ -1321,4 +1321,34 @@ suite("nereids_scalar_fn_Array") {
exception("errCode = 2")
}

// array_min/max with nested array for args
test {
sql "select array_min(array(1,2,3),array(4,5,6));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}
test {
sql "select array_max(array(1,2,3),array(4,5,6));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}

test {
sql "select array_min(array(split_by_string('a,b,c',',')));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}
test {
sql "select array_max(array(split_by_string('a,b,c',',')));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,35 @@ suite("test_array_functions_by_literal") {
sql """select array_apply(split_by_string("amory,is,better,committing", ","), '!=', '');"""
exception("No matching function")
}
// array_min/max with nested array for args
test {
sql "select array_min(array(1,2,3),array(4,5,6));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}
test {
sql "select array_max(array(1,2,3),array(4,5,6));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}

test {
sql "select array_min(array(split_by_string('a,b,c',',')));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}
test {
sql "select array_max(array(split_by_string('a,b,c',',')));"
check{result, exception, startTime, endTime ->
assertTrue(exception != null)
logger.info(exception.message)
}
}

}