Skip to content

Conversation

@poolieweb
Copy link

When using 'CAST' to a type of 'JSON' in a Athena Query Json type causes an error.

@tejasmanohar
Copy link
Contributor

tejasmanohar commented Feb 1, 2019

What Go type is returned for JSON? []byte?

@poolieweb
Copy link
Author

poolieweb commented Feb 1, 2019

Normally []byte , but I struggled with this for a while. Looking at my results and here [https://prestodb.github.io/docs/current/functions/json.html]
When casting to json you get no dictionary keys for the return object, which is kind of expected with row centric SQL, but then this does not allow []byte go unmarshal, unless I'm missing something.
Also I was thinking more in line of keeping to the SQL type primitives then go view point. But this is certainly open discussion, the main point was the err caused by the unmapped json type.

@tejasmanohar
Copy link
Contributor

tejasmanohar commented Feb 1, 2019

I like []byte... that's how I've seen jackc/pgx, the postgres driver I use do it, but it would be odd if Go could not unmarshal it. Could you show an example of that?

Also, could you add tests illustrating the expected usage of the JSON type? That's a requirement to merge. Thanks for putting this PR together!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants