2
votes

Snowflake documentation says that VARCHAR columns are limited to 16 MB uncompressed https://docs.snowflake.net/manuals/sql-reference/data-types-text.html#data-types-for-text-strings

VARCHAR holds unicode characters.  The maximum length is 16 MB (uncompressed). The maximum number of Unicode characters that can be stored in a VARCHAR column depends on whether the characters are singlebyte or multibyte:

Singlebyte
16,777,216

Multibyte
Between 8,388,608 (2 bytes per character) and 4,194,304 (4 bytes per character)

If a length is not specified, the default is the maximum length.

Snowflake documentation says that VARCHAR data is automatically converted to JavaScript string data type.
https://docs.snowflake.net/manuals/sql-reference/stored-procedures-usage.html#sql-and-javascript-data-type-mapping

QUESTION: If I call a Snowflake procedure (or JavaScript UDF) and pass in the VARCHAR data from a table, is there a size limitation in the Snowflake Procedure, or will it handle a 16MB string variable?

1

1 Answers

2
votes

JavaScript will handle up to 16MB:

CREATE OR REPLACE FUNCTION MaxParam("STRING" VARCHAR)
RETURNS STRING LANGUAGE JAVASCRIPT STRICT IMMUTABLE AS
'return STRING;';

CREATE TABLE T AS SELECT LPAD('111', 16777216, '0') STR;
SELECT MaxParam(STR) FROM T;
=> 0000000000000000000000000000000000000...

SELECT MaxParam(LPAD('111', 16777217, '0'));
=> String '(padded string)' is too long and would be truncated
(Error message is from LPAD, not JS)