I am attempting to use the MERGE statement together with a MAP column from a temporary SELECT/VALUES statement, but I get a strange error.
The error is:
cast function for type MAP is not defined
The SQL I attempt to use is:
-- Create table
CREATE TABLE IF NOT EXISTS TestTable
(
Id VARCHAR,
Dimensions MAP<VARCHAR, VARCHAR>
);
TRUNCATE TABLE TestTable;
-- Base Data
INSERT INTO TestTable
VALUES ('Number1', MAP['Key1', 'Value1']);
-- Merge
-- ERROR: cast function for type MAP is not defined
MERGE INTO TestTable AS D
USING (
SELECT *
FROM (VALUES('Number1', MAP['Key1', 'Value2'])) AS SourceTable(Id, Dimensions)
) AS S
ON (D.Id = S.Id)
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT *;
-- Validation
SELECT * FROM TestTable;