3

I am trying to query a jsonb field in PostgreSQL in drill and read it as if were coming from a json storage type but am running into trouble. I can conver from text to json but cannot seem to query the json object. At least I think I can convert to JSON. My goal is to avoid reading through millions of uneven json objects from PostgreSQL, perform joins and things with text files such as CSV files and XML files. Is there a way to query the text field as if it were coming from a json storage type without writing large files to disk?

The goal is to generate results implicitly which PostgreSQL nor Pentaho do and integrate these data sets with others of any format.

Attempt:

SELECT * FROM (SELECT convert_to(json_field,'JSON') as data FROM postgres.mytable) as q1

Sample Result:

[B@7106dd

Attempt to existing field that should be in any json object:

  SELECT data[field] FROM (SELECT convert_to(json_field,'JSON') as data FROM postgres.mytable) as q1

Result:

   null

Attempting to do anything with jsonb results in a Null Pointer Error.

Andrew Scott Evans
  • 1,003
  • 12
  • 26

0 Answers0