Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 11:32 PM
Hi @SagarJi ,
According to the documentation updates to the nested columns are not supported:
What you can do you can construct the whole struct and update the parent:
MERGE INTO mydataset AS target
USING CURRENT_BATCH AS incoming
ON target.parent1.companyId = incoming.parent1.companyId
AND target.parent1.id = incoming.parent1.id
AND incoming.is_deleted <> 'N'
WHEN MATCHED AND incoming.parent2.dateTimeUpdated > target.parent2.dateTimeUpdated
THEN UPDATE SET
target.is_deleted = incoming.is_deleted,
target.parent2 = struct(
target.parent2.field1 AS field1, -- Replace 'field1' with actual field names
target.parent2.field2 AS field2, -- Replace 'field2' with actual field names
-- Include all other fields from parent2 here, keeping their values unchanged
incoming.parent2.dateTimeUpdated AS dateTimeUpdated -- Update this field
)
WHEN NOT MATCHED THEN INSERT *