diff --git a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala index 6a0196e2b18..66ea6c98669 100644 --- a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala +++ b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala @@ -489,6 +489,20 @@ class GlutenFunctionValidateSuite extends GlutenClickHouseWholeStageTransformerS runQueryAndCompare(sql1)(checkGlutenPlan[ProjectExecTransformer]) } + test("test str2map with nullable string input") { + val sql = + """ + |select id, str_to_map(str, ',', ':') + |from ( + | select id, + | if(id = 1, cast(null as string), concat('k:', cast(id as string))) as str + | from range(4) + |) + |order by id + |""".stripMargin + runQueryAndCompare(sql)(checkGlutenPlan[ProjectExecTransformer]) + } + test("test parse_url") { val sql1 = """ diff --git a/cpp-ch/local-engine/Functions/SparkFunctionStrToMap.cpp b/cpp-ch/local-engine/Functions/SparkFunctionStrToMap.cpp index 8936ea0d04b..e9c1d80c066 100644 --- a/cpp-ch/local-engine/Functions/SparkFunctionStrToMap.cpp +++ b/cpp-ch/local-engine/Functions/SparkFunctionStrToMap.cpp @@ -240,7 +240,7 @@ class SparkFunctionStrToMap : public DB::IFunction for (size_t i = 0, n = offsets.size(); i < n; ++i) { - if (null_map && (*null_map)[n] != 0) + if (null_map && (*null_map)[i] != 0) col_map->insertDefault(); else {