You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MERGE INTO table_a AS target USING(
SELECT
pk,
my_array
FROM table_b
) AS source ONsource.pk=target.pk
WHEN MATCHED THEN UPDATESETtarget.my_array= ARRAY_DISTINCT(CONCAT(source.my_array, target.my_array))
WHEN NOT MATCHED THEN INSERT (pk, my_array)
VALUES (
source.pk,
source.my_array
)
As the WHEN MATCHED is a function then this should be possible but there's a transformation applied that strips out the table aliases in the THEN part.
This then leads us to an ambiguous column error as target.my_array is transformed to just my_array.
Might a solution be to also consider if the column's parent is a function? In which case if the merge target is referenced then it is to remove ambiguity.
I'll raise a PR with such a solution shortly and will await comments.
Official Documentation
Please include links to official SQL documentation related to your issue.
The text was updated successfully, but these errors were encountered:
Fully reproducible code snippet
As the WHEN MATCHED is a function then this should be possible but there's a transformation applied that strips out the table aliases in the THEN part.
This then leads us to an ambiguous column error as target.my_array is transformed to just my_array.
Might a solution be to also consider if the column's parent is a function? In which case if the merge target is referenced then it is to remove ambiguity.
I'll raise a PR with such a solution shortly and will await comments.
Official Documentation
Please include links to official SQL documentation related to your issue.
The text was updated successfully, but these errors were encountered: