0

getting the below error Value of type ARRAY<STRUCT<value ARRAY>> cannot be assigned to M.preferences_testing, which has type STRING

MERGE table1 M USING (
 
select  _id,ARRAY(SELECT AS STRUCT value from unnest(preferences) as p where p.name="sendOnly")  as prefer from table2    
  
) S ON M._ID = S._ID WHEN MATCHED THEN 
UPDATE 
SET 
  M._ID = S._ID, 
  M.preferences_testing=s.prefer  // here getting error
  WHEN NOT MATCHED THEN INSERT (
    _ID,    
    preferences_testing
  ) 
VALUES 
  (
 _ID,   
 prefer
  )

table 2 structure

fullname    mode            type    description
_id         NULLABLE    STRING  
preferences REPEATED    RECORD  
preferences.value   REPEATED    STRING  
preferences.name    NULLABLE    STRING  

Table 1 structure

fullname    mode    type    description
preferences_testing NULLABLE    STRING  
_Id NULLABLE    STRING  

I tried to convert ARRAY<STRUCT<value ARRAY>> to String but nothing worked

0 Answers0