gpt4 book ai didi

snowflake-cloud-data-platform - Snowflake 存储过程中的最大 JavaScript 字符串大小

转载 作者:行者123 更新时间:2023-12-04 10:54:35 24 4
gpt4 key购买 nike

Snowflake 文档说 VARCHAR 列限制为 16 MB 未压缩 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 文档说 VARCHAR 数据会自动转换为 JavaScript 字符串数据类型。
https://docs.snowflake.net/manuals/sql-reference/stored-procedures-usage.html#sql-and-javascript-data-type-mapping

问题:如果我调用 Snowflake 过程(或 JavaScript UDF)并从表中传入 VARCHAR 数据,Snowflake 过程是否有大小限制,或者它是否会处理 16MB 的字符串变量?

最佳答案

JavaScript 最多可处理 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)

关于snowflake-cloud-data-platform - Snowflake 存储过程中的最大 JavaScript 字符串大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59295563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com