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

Translate optional map/arrays with defaults to Avro without breaking #955

Closed
wants to merge 2 commits into from

Conversation

dg-builder
Copy link
Contributor

@dg-builder dg-builder commented Dec 14, 2023

This PR changes the translation of default values for optional fields when TRANSLATE_DEFAULT is enabled. Before, there were cases (especially for nested records) where non-null default values would not be translated. This change enables translating default values (excluding unions, records, and typerefs).

@dg-builder dg-builder marked this pull request as ready for review December 14, 2023 02:02
message(path,
"cannot translate absent optional field (to have null value) because this field is optional and has a default value"));
DataSchema.Type fieldDefaultValueType = field.getType().getType();
// punt on other default values for now (too complex to handle)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are not handling all cases, what usecases do we unblock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Python Gradle plugin (LI internal) always translates to Avro. I will share the exact PR in Slack.

"cannot translate absent optional field (to have null value) because this field is optional and has a default value"));
DataSchema.Type fieldDefaultValueType = field.getType().getType();
// punt on other default values for now (too complex to handle)
if (fieldDefaultValueType == DataSchema.Type.UNION || fieldDefaultValueType == DataSchema.Type.RECORD
Copy link
Contributor

Choose a reason for hiding this comment

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

In #133, it already ruled out UNION case? Also for TYPEREF, we should look at dereferencedType?

@dg-builder
Copy link
Contributor Author

closing for now. will reopen a broader solution later.

@dg-builder dg-builder closed this Dec 18, 2023
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