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: allow empty structs in schema inference #5656

Merged
merged 3 commits into from
Jun 19, 2020

Conversation

agavra
Copy link
Contributor

@agavra agavra commented Jun 19, 2020

Description

Previously, empty structs would be formatted as STRUCT<> in the SqlSchemaFormatter (which for some reason is used independently of SqlFormatter, we should dig into that) which would cause parsing to fail because <> is it's own symbol for "not equal to".

This code path was not used in master after #4637 so it was no longer happening. That change has a relatively large surface area, so for the backport I am making the most targeted change possible to address the edge case.

Testing done

Added a unit test, which fails before this fix.

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 #")

@agavra agavra changed the base branch from master to 5.5.x June 19, 2020 17:50
@agavra agavra marked this pull request as ready for review June 19, 2020 18:12
@agavra agavra requested a review from a team as a code owner June 19, 2020 18:12
@@ -161,6 +161,9 @@ public String visitMap(final Schema schema, final String key, final String value
}

public String visitStruct(final Schema schema, final List<? extends String> fields) {
if (fields.isEmpty()) {
return "STRUCT< >";
}
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, what does the below collector return with empty fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

STRUCT<>

@agavra agavra changed the title fix: allow empy structs in schema inference fix: allow empty structs in schema inference Jun 19, 2020
@agavra agavra merged commit 3c38c8c into confluentinc:5.5.x Jun 19, 2020
@agavra agavra deleted the 5.5.x-struct-fix branch June 19, 2020 21:26
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