This works ok, thank you.
I overlooked this because of binary output.. and it's actually text and
furthermore don't have to care about varchar size as with 'cast'.
As of varchar you're right, but at the moment it's required because of 3rd
party lib that takes a string as an argument.
Unfortunately, I have one more issue with geojson and drill.
It works ok with simple geometries like points. Trying to query files with more
complex types like polygons it fails:
Error: UNSUPPORTED_OPERATION ERROR: In a list of type FLOAT8, encountered a
value of type LIST. Drill does not support lists of different types.
Line 1
Column 43
Field coordinates
...
It looks like drill has problems with arrays of arrays like in this example:
{"type":"Polygon","coordinates":[[[-93.23172199999999,42.208886],[-93.001674,42.209267],[-92.76746299999999,42.210139999999996],[-92.765999,41.862373],[-93.231858,41.862711],[-93.23172199999999,42.208886]]]}
but that's the way it's defined in specs:
http://geojson.org/geojson-spec.html#id4
On Thu, Feb 11, 2016 at 8:23 PM, Jason Altekruse <[email protected]>
wrote:
> I think what you are looking for is covert_to( column_name, 'JSON')
>
> That being said, are you going to be parsing this JSON in the function? I
> think it would make more sense to just have the function take the complex
> input.
>
> The only case where I would suggest taking in JSON, and parsing it in a
> function is if you had a bunch of source data that would put JSON embedded
> in a varchar upon a standard read (JSON embedded in a database, parquet
> file, JSON string (yes amazingly people do this)) and you want to save
> users the hassle of calling convert_from on the varchar.
>
> Adding complexity to the query so that your function can take the varchar
> seems counter-intuitive to me.
>
> On Thu, Feb 11, 2016 at 11:13 AM, Karol Potocki <[email protected]> wrote:
>
> > Hi, I am writing a UDF to convert parts of geoJson to other representation.
> > Having a query like this:
> >
> > select json.features.geometry as geoJson from (select FLATTEN(features)
> > as features from dfs.`/home/k255/CA-cities.json`) json limit 2;
> >
> > and result:
> >
> > {"type":"Point","coordinates":[-121.2785588,38.1746398]}
> > {"type":"Point","coordinates":[-121.9591252,37.3946626]}
> >
> > I need to pass the output (which is map) to UDF which expects string
> > (VarCharHolder) to pass it to other function inside.
> > Is there a way in drill (other than handling FieldReader) to convert this
> > part of a json object to string like this:
> >
> > '{"type":"Point","coordinates":[-121.2785588,38.1746398]}'
> > '{"type":"Point","coordinates":[-121.9591252,37.3946626]}'
> >
> > ?
> >
> > Thanks,
> > Karol Potocki
> >