如何在Azure Synapse Analytics中使用tsql使用无服务器SQL池创建外部表:
我在名为“companyDetail”的表中有一个“employeeInfo”列。这是创建“companyDetail”表的查询:
CREATE EXTERNAL TABLE companyDetail
(
companyName varchar(100),
employeeInfo varchar(2048)
)
WITH
(
LOCATION = '/all_parquet_files/*.parquet',
DATA_SOURCE = parquet_datasource,
FILE_FORMAT = parquet
)
companyDetail表数据:
companyName| employeeInfo
----------------------------
ABC | {name: Ramesh, age:32 years}
ABC | {name: Mohan, experience:2 years}
DEF | {name: Dinesh, age:39, experience:5 years}
HIJ |
DEF | {name: Mohit}
我必须从这个数据创建一个外部表'employee',它应该有这样的结果:
companyName| employeeKey | employeeValue
------------------------------------------
ABC | name | Ramesh
ABC | age | 32 years
ABC | name | Mohan
ABC | experience | 2 years
ABC | name | Dinesh
ABC | age | 39
ABC | experience | 2 years
HIJ | |
DEF | name | Mohit
1条答案
按热度按时间elcex8rz1#
一种方法是将数据从外部表导入到临时表或表变量中,然后对导入的数据使用OPENJSON函数将数据翻转到列中。例如:
参见:OPENJSON