From 370475ecd4a95e94237cdbe99ba2e2fb11863a5f Mon Sep 17 00:00:00 2001 From: Bing Li Date: Tue, 28 Nov 2023 14:15:14 -0800 Subject: [PATCH] add error message --- .../snowflake/snowpark/internal/ErrorMessage.scala | 9 ++++++++- .../com/snowflake/snowpark/ErrorMessageSuite.scala | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/snowflake/snowpark/internal/ErrorMessage.scala b/src/main/scala/com/snowflake/snowpark/internal/ErrorMessage.scala index 505b2b6d..21db9dea 100644 --- a/src/main/scala/com/snowflake/snowpark/internal/ErrorMessage.scala +++ b/src/main/scala/com/snowflake/snowpark/internal/ErrorMessage.scala @@ -153,7 +153,11 @@ private[snowpark] object ErrorMessage { "0420" -> "Invalid RSA private key. The error is: %s", "0421" -> "Invalid stage location: %s. Reason: %s.", "0422" -> "Internal error: Server fetching is disabled for the parameter %s and there is no default value for it.", - "0423" -> "Invalid input argument, Session.tableFunction only supports table function arguments") + "0423" -> "Invalid input argument, Session.tableFunction only supports table function arguments", + "0424" -> + """Invalid input argument type, the input argument type of Explode function should be either Map or Array types. + |The input argument type: %s + |""".stripMargin) // scalastyle:on /* @@ -393,6 +397,9 @@ private[snowpark] object ErrorMessage { def MISC_INVALID_TABLE_FUNCTION_INPUT(): SnowparkClientException = createException("0423") + def MISC_INVALID_EXPLODE_ARGUMENT_TYPE(argumentType: String): SnowparkClientException = + createException("0424", argumentType) + /** * Create Snowpark client Exception. * diff --git a/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala b/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala index 072c73e8..bfeddd72 100644 --- a/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala +++ b/src/test/scala/com/snowflake/snowpark/ErrorMessageSuite.scala @@ -830,4 +830,15 @@ class ErrorMessageSuite extends FunSuite { ex.message.startsWith("Error Code: 0423, Error message: Invalid input argument, " + "Session.tableFunction only supports table function arguments")) } + + test("MISC_INVALID_EXPLODE_ARGUMENT_TYPE") { + val ex = ErrorMessage.MISC_INVALID_EXPLODE_ARGUMENT_TYPE(types.IntegerType.typeName) + assert(ex.telemetryMessage.equals(ErrorMessage.getMessage("0424"))) + assert( + ex.message.startsWith( + "Error Code: 0424, Error message: " + + "Invalid input argument type, the input argument type of " + + "Explode function should be either Map or Array types.\n" + + "The input argument type: Integer")) + } }