我每天从数据源中提取数据并将其存储在 Parquet 中,然后在 synapse 中创建一个外部表。我想用每天提取的数据不断更新外部表。我创建了一个笔记本来创建临时表,插入新数据并合并到旧数据,但它不起作用。
CREATE TABLE #TempTable
(
DATE DATE,
SMD INT,
ERK VARCHAR(50),
LK DATETIME,
LDATE DATE,
LG DATETIME,
K DATETIME,
G DATETIME,
IZAR INT,
BSL INT,
PERS INT,
WORK_TIME_HOURS DECIMAL(10, 2)
);
BULK INSERT #TempTable
FROM 'frr/ff_test/*.parquet'
WITH (
DATA_SOURCE = 'PersData',
FILE_FORMAT = 'ParquetFF'
);
MERGE INTO [Gf].[Gon_test] AS target
USING TempTable AS source
ON target.smand = source.smand
WHEN MATCHED THEN
UPDATE SET
target.DATE = source.DATE,
target.LK = source.LK,
target.LD = source.LD,
target.LG = source.LG,
target.K = source.K,
target.G = source.G,
target.IZAR = source.IZAR,
target.BSL = source.SBSL,
target.PERS = source.SPERS,
target.WORK_TIME_HOURS = source.WORK_TIME_HOURS
WHEN NOT MATCHED THEN
INSERT (
DATE,
SMAND,
ERK,
LK,
LD,
LG,
KN,
G,
IZR,
BSL,
PERS,
WORK_TIME
)
VALUES (
source.DATE,
source.AND,
source.ERK,
source.LK,
source.LD,
source.LG,
source.K,
source.G,
source.IZAR,
source.BSL,
source.PERS,
source.WORK_TIME
);
DROP TABLE #TempTable;