为什么 repeat() 函数不在 Snowflake 中重复空格?

Why doesn't the repeat() function repeat spaces in Snowflake?

我正在尝试用空格填充 Snowflake 中的 varchar 字段。我正在使用重复功能。 LPAD功能同样令人失望。

select concat('|', repeat(' ',10), '|') concat_result
union
select concat('|', repeat('_',10), '|')

这是 UI 的产物,而不是数据中发生的事情。试试这个,你就会明白我的意思了:

SELECT LENGTH( concat('|', repeat(' ',10), '|') );

结果:12

要生成特定数量的空格,可以使用内置 SPACE 函数:

SPACE(n)

Builds a string consisting of the specified number of blank spaces.

SELECT SPACE(10)