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

CE-534: Add support to handle producing union type of multiple records #222

Merged
merged 8 commits into from
Mar 6, 2025

Conversation

angad-singh
Copy link
Member

Description

Added support to detect the right schema type from a UnionSchema

Fixes https://flippit.atlassian.net/browse/CIE-534

Type of change

Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested the change on Item-Platform using this branch (to reproduce the issue) https://github.com/wishabi/item-platform/commit/560cdd748b9335dc9dee9aeeaa65e94f23cb1988
Verified that the existing Kafka specs pass on Item-Platform

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added a line in the CHANGELOG describing this change, under the UNRELEASED heading
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Member

@dorner dorner left a comment

Choose a reason for hiding this comment

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

Just one question - otherwise looks good!

_is_integer_string?(val) ||
int_classes.any? { |klass| val.is_a?(klass) }
when :float, :double
val.is_a?(Numeric) || _is_float_string?(val)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be Float instead of Numeric?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just tested with Float and it still works so I changed it to Float. Added a test for it as well. I copied it from this method for reference https://github.com/flipp-oss/deimos/blob/master/lib/deimos/schema_backends/avro_schema_coercer.rb#L56C7-L58C19

dorner
dorner previously approved these changes Feb 26, 2025
When determining data types from a union of different data types, compare the fields for schema type: record with the values to determine the right schema type.
@angad-singh angad-singh changed the base branch from master to main March 5, 2025 20:05
@dorner dorner merged commit 91a65ea into main Mar 6, 2025
5 of 6 checks passed
@dorner dorner deleted the CIE-534 branch March 6, 2025 14:17
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