0

我有一个包含两列的 csv 文件。第一列是 id,第二列是压缩的 GZIP 二进制数据。我想将此记录加载到雪花表中,其中两列 id 作为数字数据类型,bin_text 作为二进制数据类型。

尝试使用“COPY into”命令加载 csv 文件(选项卡作为分隔符),但 GZIP 压缩的二进制数据有多个新行,雪花将其视为单独的记录。

我需要将具有多个新行的整个 GZIP 压缩二进制数据加载到单个记录中。

请帮忙。

表结构 - id 为数字,compress_data 为二进制

例如,第一条记录 - 1,gzip of ("hello world。这是雪花示例。我有一些疑问,所以用 stackoverflow 来解决疑问。问题是将二进制数据加载到雪花表中。我有一个 csv有两列的文件。第一列是 id,第二列是压缩的 GZIP 二进制数据。我想将此记录加载到 Snowflake 表中,其中两列 id 作为数字数据类型,bin_text 作为二进制数据类型。尝试加载带有“COPY into”命令的 csv 文件(选项卡作为分隔符),但 GZIP 压缩的二进制数据有多个新行,雪花认为是单独的记录。我需要将具有多个新行的整个 GZIP 压缩二进制数据加载到单个记录中。”)。

要生成文本的压缩格式,我使用以下命令:

echo "hello world. This is snowflake example. I am having some doubts so went for stackoverflow to clear the doubts. The issue is to load the bianry data into snowflake table. I have a csv file which has two columns. First Column is an id and second column is the compressed GZIP binary data. I want to load this record into the Snowflake table with having two columns id as number data type and bin_text as binary data type. Tried to load csv file(tab as seperator) with "COPY into" command but the GZIP compressed binary data has a multiple new lines which snowflake considers as seperate recod. I need to load the whole GZIP compressed binary data which has multiple new lines into a single record." | gzip -cf9 | wc -l

此命令生成 4 行作为压缩输出。我想将这 4 行存储为一条记录。

输出文件是存储在 Snowflake 内部阶段的 CSV(制表符分隔)。

使用的复制命令选项:

copy into compress
from (
select
t.$1,
t.$2
from <INTERNAL STAGE> t
)
file_format = ( type = csv
field_delimiter='\t' escape_unenclosed_field=none
binary_format=UTF8);
4

0 回答 0