diff --git a/src/main/scala/com/snowflake/snowpark/DataFrame.scala b/src/main/scala/com/snowflake/snowpark/DataFrame.scala index 9d08f924..54c43c49 100644 --- a/src/main/scala/com/snowflake/snowpark/DataFrame.scala +++ b/src/main/scala/com/snowflake/snowpark/DataFrame.scala @@ -2012,7 +2012,8 @@ class DataFrame private[snowpark] ( joinTableFunction( tableFunctions.flatten.call(Map("input" -> Column(expr), "mode" -> lit("object"))), partitionByOrderBy).select(columns ++ Seq(Column("KEY"), Column("VALUE"))) - case _ => null + case otherType => + throw ErrorMessage.MISC_INVALID_EXPLODE_ARGUMENT_TYPE(otherType.typeName) } } diff --git a/src/test/scala/com/snowflake/snowpark_test/TableFunctionSuite.scala b/src/test/scala/com/snowflake/snowpark_test/TableFunctionSuite.scala index 4d110639..1eb389f2 100644 --- a/src/test/scala/com/snowflake/snowpark_test/TableFunctionSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/TableFunctionSuite.scala @@ -400,10 +400,26 @@ class TableFunctionSuite extends TestData { parse_json(df("a")) .cast(types.MapType(types.StringType, types.IntegerType)) .as("a")) - df1.select(tableFunctions.explode(df1("a"))).show() checkAnswer( df1.select(lit(1), tableFunctions.explode(df1("a")), df1("a")("a")), Seq(Row(1, "a", "1", "1"), Row(1, "b", "2", "1"))) } + test("explode with other column") { + val df = Seq("""{"a":1, "b": 2}""").toDF("a") + val df1 = df.select( + parse_json(df("a")) + .as("a")) + val error = intercept[SnowparkClientException] { + df1.select(tableFunctions.explode(df1("a"))).show() + } + assert( + error.message.contains( + "the input argument type of Explode function should be either Map or Array types")) + assert( + error.message.contains( + "The input argument type: Variant")) + } + + }