替代通过雪花中的目标表进行JSON扁平化

问题描述 投票:0回答:1

[每雪花:https://docs.snowflake.net/manuals/user-guide/json-basics-tutorial-copy-into.html我创建了一个目标表(Testing_JSON),该表是包含上载JSON文件的单个Variant列。

我的问题是如何剪切创建此“目标表(即Testing_JSON)”的内容,该“目标表”是一个变量列,我必须引用该变量来创建我想要的实际且唯一的表(TABLE1),其中包含扁平化的表JSON。我没有找到从桌面读取JSON文件并“即时解析”以创建展平表VIA THE UI的方法。我不使用CLI,因为我知道可以使用PUT / COPY INTO

来完成
create or replace temporary table TABLE1 AS
SELECT 
VALUE:col1::string AS COL_1,
VALUE:col2::string AS COL_2,
VALUE:col3::string AS COL_3

from TESTING_JSON 
  , lateral flatten( input => json:value);
json flatten snowflake-datawarehouse lateral
1个回答
0
投票

您将需要在桌面上完成几个步骤。

  1. 使用SnowSQL或其他工具将JSON文件更新为blob存储:https://docs.snowflake.net/manuals/sql-reference/sql/put.html
  2. 使用COPY INTO语句将数据直接加载到要加载到的展平表中。这将需要在COPY INTO中使用SELECT语句:https://docs.snowflake.net/manuals/sql-reference/sql/copy-into-table.html

这里有一个很好的例子:

https://docs.snowflake.net/manuals/user-guide/querying-stage.html#example-3-querying-elements-in-a-json-file


0
投票

您将需要在桌面上完成几个步骤。

  1. 使用SnowSQL或其他工具将JSON文件更新为blob存储:https://docs.snowflake.net/manuals/sql-reference/sql/put.html
  2. 使用COPY INTO语句将数据直接加载到要加载到的展平表中。这将需要在COPY INTO中使用SELECT语句:https://docs.snowflake.net/manuals/sql-reference/sql/copy-into-table.html

这里有一个很好的例子:

https://docs.snowflake.net/manuals/user-guide/querying-stage.html#example-3-querying-elements-in-a-json-file

© www.soinside.com 2019 - 2024. All rights reserved.