Home > database >  Column attributes of type STRUCT cannot be used in SELECT DISTINCT
Column attributes of type STRUCT cannot be used in SELECT DISTINCT

Time:03-17

I have this sql statement

Select distinct _data.attributes from rd-bigdata-lake-prd.lake_gcs.xyz

and I get this error

400 Column attributes of type STRUCT cannot be used in SELECT DISTINCT

The value of _data.attributes is

{"url":"/services/data/v52.0/sobjects/Message/123456789","type":"Message"}

How to change the sql statement, that the field _data.attributes is readable with select distinct? I tried to cast _data.attributes to string. But it doesn't work.

CodePudding user response:

Convert the struct to string using to_json

select distinct 
       to_json(_data.attributes)

from   rd-bigdata-lake-prd.lake_gcs.xyz
  • Related