diff --git a/cpp-ch/local-engine/Parser/scalar_function_parser/elementAt.cpp b/cpp-ch/local-engine/Parser/scalar_function_parser/elementAt.cpp index 021e9245e288..a3a2549e2ff1 100644 --- a/cpp-ch/local-engine/Parser/scalar_function_parser/elementAt.cpp +++ b/cpp-ch/local-engine/Parser/scalar_function_parser/elementAt.cpp @@ -58,6 +58,13 @@ class FunctionParserElementAt : public FunctionParser if (isMap(arg_type)) { const auto * map_arg = parsed_args[0]; + const DataTypeMap * map_type = checkAndGetDataType(removeNullable(map_arg->result_type).get()); + if (isNothing(map_type->getKeyType())) + { + const DataTypePtr value_type = map_type->getValueType(); + const auto * null_const_node = addColumnToActionsDAG(actions_dag, makeNullable(value_type), Field{}); + return null_const_node; + } const auto * key_arg = parsed_args[1]; const auto * result_node = toFunctionNode(actions_dag, "arrayElementOrNull", {map_arg, key_arg}); return convertNodeTypeIfNeeded(substrait_func, result_node, actions_dag); diff --git a/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala b/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala index 0091c0c4dd14..b8171bc63362 100644 --- a/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala +++ b/gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala @@ -159,7 +159,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenDataFrameComplexTypeSuite] enableSuite[GlutenDataFrameFunctionsSuite] .exclude("map with arrays") - .exclude("element_at function") .exclude("flatten function") .exclude("aggregate function - array for primitive type not containing null") .exclude("aggregate function - array for primitive type containing null") @@ -655,7 +654,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenCollectionExpressionsSuite] .exclude("ArraysZip") // wait for https://github.com/ClickHouse/ClickHouse/pull/69576 .exclude("Sequence of numbers") - .exclude("elementAt") .exclude("Shuffle") .exclude("SPARK-33386: element_at ArrayIndexOutOfBoundsException") .exclude("SPARK-33460: element_at NoSuchElementException") diff --git a/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala b/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala index 77be9e78c06f..731f66c5303a 100644 --- a/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala +++ b/gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala @@ -177,7 +177,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenDataFrameComplexTypeSuite] enableSuite[GlutenDataFrameFunctionsSuite] .exclude("map with arrays") - .exclude("element_at function") .exclude("flatten function") .exclude("aggregate function - array for primitive type not containing null") .exclude("aggregate function - array for primitive type containing null") @@ -683,7 +682,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenCollectionExpressionsSuite] .exclude("ArraysZip") // wait for https://github.com/ClickHouse/ClickHouse/pull/69576 .exclude("Sequence of numbers") - .exclude("elementAt") .exclude("Shuffle") .exclude("SPARK-33386: element_at ArrayIndexOutOfBoundsException") .exclude("SPARK-33460: element_at NoSuchElementException") diff --git a/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala b/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala index d73e44fdc0cd..86d235dc8894 100644 --- a/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala +++ b/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala @@ -179,7 +179,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenDataFrameComplexTypeSuite] enableSuite[GlutenDataFrameFunctionsSuite] .exclude("map with arrays") - .exclude("element_at function") .exclude("flatten function") .exclude("aggregate function - array for primitive type not containing null") .exclude("aggregate function - array for primitive type containing null") @@ -572,7 +571,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenCollectionExpressionsSuite] .exclude("ArraysZip") // wait for https://github.com/ClickHouse/ClickHouse/pull/69576 .exclude("Sequence of numbers") - .exclude("elementAt") .exclude("Shuffle") .exclude("SPARK-33386: element_at ArrayIndexOutOfBoundsException") .exclude("SPARK-33460: element_at NoSuchElementException") diff --git a/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala b/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala index 2bd1bacb4f8f..3fe2764c74ec 100644 --- a/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala +++ b/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/clickhouse/ClickHouseTestSettings.scala @@ -179,7 +179,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenDataFrameComplexTypeSuite] enableSuite[GlutenDataFrameFunctionsSuite] .exclude("map with arrays") - .exclude("element_at function") .exclude("flatten function") .exclude("aggregate function - array for primitive type not containing null") .exclude("aggregate function - array for primitive type containing null") @@ -572,7 +571,6 @@ class ClickHouseTestSettings extends BackendTestSettings { enableSuite[GlutenCollectionExpressionsSuite] .exclude("ArraysZip") // wait for https://github.com/ClickHouse/ClickHouse/pull/69576 .exclude("Sequence of numbers") - .exclude("elementAt") .exclude("Shuffle") .exclude("SPARK-33386: element_at ArrayIndexOutOfBoundsException") .exclude("SPARK-33460: element_at NoSuchElementException")