Skip to content
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

fix: /inserts-stream endpoint now accepts complex types #5469

Merged
merged 6 commits into from
May 27, 2020

Conversation

vcrfxia
Copy link
Contributor

@vcrfxia vcrfxia commented May 22, 2020

Description

Three changes in this PR:

(1) Prior to this PR, inserting a row with a complex column type (array, map, or struct) via /inserts-stream would fail since the SqlValueCoercer can't handle JsonArray or JsonObject. This PR fixes the bug.

(2) This PR adds server-side and client-side test coverage for complex types including decimal, array, and map. A follow-up PR will add coverage for struct as well.

(3) Besides (1), the only other non-test change in this PR is in response to #5448 (comment): rather than serializing BigDecimal as double on the client, we instead serialize BigDecimal as string in order to avoid loss of precision. The drawback is we now have an inconsistency where the decimal type is treated differently in terms of allowable casts, compared to the other numeric types. For example:

final KsqlObject obj = new KsqlObject().put("f1", new BigDecimal("1.13")).put("f2", 12.23);
System.out.println(obj.getString("f1")); // This succeeds
System.out.println(obj.getString("f2")); // This fails with "java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.CharSequence"

Testing done

Tests pass.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@vcrfxia vcrfxia requested a review from a team as a code owner May 22, 2020 23:36
@vcrfxia vcrfxia requested a review from purplefox May 22, 2020 23:36
@vcrfxia vcrfxia changed the title test: client and server integration tests for complex types fix: /inserts-stream endpoint now accepts complex types May 22, 2020
Copy link
Contributor

@purplefox purplefox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vcrfxia vcrfxia merged commit 0840160 into confluentinc:master May 27, 2020
@vcrfxia vcrfxia deleted the insert-complex-types branch May 27, 2020 22:29
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.

None yet

2 participants