-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DynamoDB: Handle container types correctly #33
Comments
First of all, thanks for your elaborations. This makes it complicated if an ARRAY contains OBJECTs, because then we cannot “simply” serialize them to JSON, but have to use the special syntax, for which there is of course no ready-made recursive serializer a la Is there any chance CrateDB could provide symmetric support on the SQL level to handle both container data types OBJECT and ARRAY equally well? |
But this won't help much when trying to insert this into a array defined type or dynamic object.
Inserting it into a dynamic object will store the json array as text instead of an array:
So the only solution seems to support the JSON -> ARRAY cast. |
Thank you so much for your evaluations. So, until CrateDB will gain that feature, we need to use the non-JSON syntax to relay ARRAY types in a generic way. Primitive inner typesIt works well for those. cr> UPDATE "foo" SET data['tags'] = ['foo', 'bar'];
UPDATE OK, 1 row affected (0.049 sec)
cr> select pg_typeof(data['tags']) from foo;
+------------------------------------+
| pg_catalog.pg_typeof(data['tags']) |
+------------------------------------+
| text_array |
+------------------------------------+ Complex inner typesIt also works well for those. cr> UPDATE "foo" SET data['supertags'] = [{foo='bar', baz='qux'}];
UPDATE OK, 1 row affected (0.052 sec)
cr> select pg_typeof(data['supertags']) from foo;
+-----------------------------------------+
| pg_catalog.pg_typeof(data['supertags']) |
+-----------------------------------------+
| object_array |
+-----------------------------------------+ So, I figure it's a bummer, but not a blocker. |
Fixed with GH-34, and released with v0.0.11. |
About
Coming from a fix to handle map/object types correctly, and corresponding attempts to introduce CrateDB SQL casts to get it right, we may have spotted an anomaly when processing JSON data on OBJECTs vs. ARRAYs.
Details
Do you think this is an anomaly that deserves a ticket on crate/crate? The first statement casts an object successfully from JSON, while the second one croaks on the list/array.
References
The text was updated successfully, but these errors were encountered: