将包含 JSON 的 Avro 文件放入 Snowflake 上的 table 结构的正确方法是什么?
What is the right way to get Avro-files containing JSON into table-structure on Snowflake?
我一直在努力将我的数据从 Azure 事件中心获取到 Snowflake 平台上的 SQL-table。如果我必须多次转换数据,我就无法思考如何正确地做到这一点。我的数据在 Avro 文件的正文中。
我刚开始做雪花。到目前为止,我已经尝试在该主题上关注 this tutorial,但它实际上并没有在视频中的任何地方保存 JSON 格式的正文。到目前为止,我已经尝试过这样的事情
CREATE DATABASE IF NOT EXISTS MY_DB;
USE DATABASE MY_DB;
CREATE OR REPLACE TABLE data_table(
"column1" STRING,
"column2" INTEGER,
"column3" STRING
);
create or replace file format av_avro_format
type = 'AVRO'
compression = 'NONE';
create or replace stage st_capture_avros
url='azure://xxxxxxx.blob.core.windows.net/xxxxxxxx/xxxxxxxxx/xxxxxxx/1/'
credentials=(azure_sas_token='?xxxxxxxxxxxxx')
file_format = av_avro_format;
copy into avro_as_json_table(body)
from(
select(HEX_DECODE_STRING(:Body))
from @st_capture_avros
);
copy into data_table("Column1", "Column2", "Column3" )
from(
select :"jsonKeyValue1", :"jsonKeyValue2", :"jsonKeyValue3"
from avro_as_json_table
);
这不起作用,因为它会产生 "SQL compilation error: COPY statement only supports simple SELECT from stage statements for import" 错误,我知道我应该在最后一条语句中使用 INSERT INTO 而不是复制,但我的问题更多是如何消除冗余 avro_as_json_table 从等式?
而不是使用
copy into avro_as_json_table(body)
from ...
尝试
INSERT INTO avro_as_json_table(body)
from ...
我一直在努力将我的数据从 Azure 事件中心获取到 Snowflake 平台上的 SQL-table。如果我必须多次转换数据,我就无法思考如何正确地做到这一点。我的数据在 Avro 文件的正文中。
我刚开始做雪花。到目前为止,我已经尝试在该主题上关注 this tutorial,但它实际上并没有在视频中的任何地方保存 JSON 格式的正文。到目前为止,我已经尝试过这样的事情
CREATE DATABASE IF NOT EXISTS MY_DB;
USE DATABASE MY_DB;
CREATE OR REPLACE TABLE data_table(
"column1" STRING,
"column2" INTEGER,
"column3" STRING
);
create or replace file format av_avro_format
type = 'AVRO'
compression = 'NONE';
create or replace stage st_capture_avros
url='azure://xxxxxxx.blob.core.windows.net/xxxxxxxx/xxxxxxxxx/xxxxxxx/1/'
credentials=(azure_sas_token='?xxxxxxxxxxxxx')
file_format = av_avro_format;
copy into avro_as_json_table(body)
from(
select(HEX_DECODE_STRING(:Body))
from @st_capture_avros
);
copy into data_table("Column1", "Column2", "Column3" )
from(
select :"jsonKeyValue1", :"jsonKeyValue2", :"jsonKeyValue3"
from avro_as_json_table
);
这不起作用,因为它会产生 "SQL compilation error: COPY statement only supports simple SELECT from stage statements for import" 错误,我知道我应该在最后一条语句中使用 INSERT INTO 而不是复制,但我的问题更多是如何消除冗余 avro_as_json_table 从等式?
而不是使用
copy into avro_as_json_table(body)
from ...
尝试
INSERT INTO avro_as_json_table(body)
from ...