-
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 CDC: Improve type mappings #25
Comments
Hi. I guess this change might be the root cause of the issue? It pretends to leave it to CrateDB to auto-cast values. Maybe that does not work for empty arrays with CrateDB? |
With a demo table in CrateDB like that... create table foo (data OBJECT(DYNAMIC));
insert into foo (data) values ('{"items": ["foo", "bar"]}'); This statement works, UPDATE "foo" SET data['items'] = []; while this statement doesn't. It raises the same error message like presented in the OP. UPDATE "foo" SET data['items'] = '[]';
ColumnValidationException[Validation failed for data: Cannot cast expression `'[]'` of type `text` to `text_array`] |
@wierdvanderhaar: Can I humbly ask you check if downgrading to commons-codec 0.0.6 could be an easy option for you? Version 0.0.7 includes a change "DynamoDB: Fixed a syntax issue with text data type in UPDATE statements", which is probably responsible for this hiccup. |
This patch includes a proposal to apply better type mapping for |
@amotl Thank you for your effort and input. The downgrade to [https://commons-codec.readthedocs.io/changes.html#v0-0-6](common-codec 0.0.6) is not really an option here because that version 0.0.7 fixed an issue raised in this https://github.com/daq-tools/commons-codec/pull/19. In general, we will need to do more to apply correct type mapping. |
... carrying over two more reports by @hlcianfagna from #24 (review). Thanks! Top-level arraysWe need a test case for the situation of a first level field being an array of objects, for instance "testarrayobj": [{"field1":1},{"field2":"abc"}] This cast is successful in CrateDB: '[{"field1":1},{"field2":"abc"}]'::ARRAY(OBJECT) String SetAnother situation is the one of a DynamoDB |
'[]'
of type text
to text_array
Hi again. We have been able to add a few follow-up fixes to improve type mappings. Thanks a stack for your support, @surister, @wierdvanderhaar, @hlcianfagna, and @hammerhead.
|
GH-34 may improve this situation already, including test cases. Do you agree?
That would be a serious anomaly to fix up, mostly because a stateless transformation routine will not know about the fact that CrateDB already may have something stored as a certain type. If we do an inquiry upfront inserting, the situation may change, but a) this adds additional complexity and b) might produce edge case situations when NO data has been inserted beforehand, and may create new kinds of ambiguities. That doesn't mean we will not implement it as advised in order to gain DWIM, but I still wanted to mention it that it's not straight-forward. If you have any idea how to solve it more elegantly, please let me know. |
I think we are in a reasonable better position now, after improving the DynamoDB translator implementation on behalf of the latest releases. In this spirit, we may close this issue, and open different / more specific ones when applicable. @wierdvanderhaar / @hlcianfagna: Please 👍 if you agree. |
Just using the chance to convey a big learning for me, which you may also like, if you didn't know yet. It is about how to use parameterized queries together with SQL CASTs, which might not be possible using the more ad hoc commons-codec/src/commons_codec/transform/dynamodb.py Lines 179 to 183 in 25eb728
I picked it up from some MSSQL or Oracle page I guess and discussed with @seut that it would be worth to also bring it more highlighted to our documentation in one way or another. It is just a small yet important detail, I believe. /cc @matkuliak |
Closing this now. Please re-open when applicable. |
Problem
Details
@wierdvanderhaar reported that when the CDC transformer processes an UPDATE event, generating an SQL statement like that
an exception is raised.
The text was updated successfully, but these errors were encountered: