FORMATMESSAGE_UDF

Snowflake does not have a function with the functionality of FORMATMESSAGE. SnowConvert generates the following Python UDF to emulate the behavior of FORMATMESSAGE.

CREATE OR REPLACE FUNCTION FORMATMESSAGE_UDF(MESSAGE STRING, ARGS ARRAY)
RETURNS STRING
LANGUAGE python
IMMUTABLE
RUNTIME_VERSION = '3.8'
HANDLER = 'format_py'
as
$$
def format_py(message,args):
  return message % (*args,)
$$;

This UDF may not work correctly on some cases:

  • Using the %I64d placeholder will throw an error.

  • If the number of substitution arguments is different than the number of place holders, it will throw an error.

  • Some unsigned placeholders like %u or %X will not behave properly when formatting the value.

  • It cannot handle message_ids.

Last updated