Druid SQL for nested object throwing StringDictionaryEncodedColumn error

66 views Asked by At

This is my query

SELECT JSON_VALUE("event.data", '$.favItems') as "fav.Items" FROM "db"

Where event.data is a nested object with a variety of values and essentially looks like this

| event.data                               | 
| {name: "", favItems: [], obj, {}, num: 0 |

However, I am getting this error

Column [event.data] is invalid type, found [class org.apache.druid.segment.column.StringDictionaryEncodedColumn] instead of [NestedDataComplexColumn]

I looked into if there was a way to turn the expr into a JSON value but it looks like it could only become a string so I cannot access within it. Was wondering if there is a way to query for values within or would I have to save it all separately...

1

There are 1 answers

0
Sergio Ferragut On

It depends on how you ingest it. Take a look at some examples where it is declared as a "COMPLEX" data type in the EXTERN table function here.

You should also be able to use PARSE_JSON at query time to produce the json object from the string column event.data.