Hello we have a strange error when try run a Merge sentence, when run only the select part works well
but when run merge we have the error “Dremio does not support casting or coercing timestamp to intervalyear”
MERGE INTO lake.scan.posts target
USING (
SELECT id_post as mergeKey, updates.*
FROM scan.preparation.fb_posts updates
WHERE updates.id_post ='x'
) as st_update
ON target.id_post = st_update.mergeKey
WHEN MATCHED THEN
UPDATE
SET SHARES = st_update.SHARES
WHEN NOT MATCHED THEN
INSERT (ID_POST,
ID_PAGE,
TEXT,
SHARES)
VALUES (st_update.ID_POST,
st_update.ID_PAGE,
st_update.TEXT,
st_update.SHARES)
The probematic part is with scan.preparation.fb_posts
that is defined as VDS with a field
(CAST(REPLACE(REPLACE(a.created_at, 'T', ' '),'+0000', '') AS TIMESTAMP)) as created_date,
when change the query to use a subselect the error not occur
select *, TO_TIMESTAMP(created_date_str, 'YYYY-MM-DD HH24:MI:SS') as created_date
from (Select a._id as id,
a._id as id_post,
a.pageId as id_page,
a.engagement as engagement,
REPLACE(REPLACE(a.created_at, 'T', ' '), '+0000', '') as created_date_str,
"timestamp" as modified_date,
a."date",
--(CAST(REPLACE(REPLACE(a."date", 'T', ' '),'+0000', '') AS TIMESTAMP)) as modified_date,
a.shares as shares,
from scan_db.qliksocial.pagePosts a) as xy
For some reason Dremio plan is wrong when planning the select statement when inside merge statement
This are the query profiles, with error and without error, I’m using last version of Dremio
ad51665b-51ba-42d3-8d23-928da546ff2d_ok.zip (38,1 KB)
4ede3a7f-7314-44f0-9bd6-8cd4f69783e5_fail.zip (30,1 KB)