Skip to content

[client] Enum conversion functionality for typed writer/reader#3447

Open
VladBanar wants to merge 2 commits into
apache:mainfrom
VladBanar:enum-conversion-functionality-for-typed-writer-reader
Open

[client] Enum conversion functionality for typed writer/reader#3447
VladBanar wants to merge 2 commits into
apache:mainfrom
VladBanar:enum-conversion-functionality-for-typed-writer-reader

Conversation

@VladBanar

@VladBanar VladBanar commented Jun 7, 2026

Copy link
Copy Markdown
  • Generative AI disclosure: Indicate whether generative AI tools were used in authoring this PR. If yes, specify the tool below.
    • No generative AI tools used
    • Yes (please specify the tool below)

Generated-by: [Claude Haiku 4.5] following the guidelines
Only for tests

Purpose

Linked issue: close #3446

when you use typed writer/reader you can't use enum as a field in POJO.

Brief change log

  • Adjusted validation logic in ConverterCommons
  • Added conversion logic for enum in FlussTypeToPojoTypeConverter:convertTextValue

Tests

  • Added ConverterCommonsTest.java FlussTypeToPojoTypeConverterTest.java

API and Format

No

Documentation

No

@VladBanar

Copy link
Copy Markdown
Author

@polyzos Please take a look i fixed checks.

@VladBanar

VladBanar commented Jun 11, 2026

Copy link
Copy Markdown
Author

@luoyuxia @MehulBatra @fresh-borzoni Could you please approve workflow

@VladBanar

Copy link
Copy Markdown
Author

@fresh-borzoni Could you please review it? :)

@fresh-borzoni fresh-borzoni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@VladBanar Thank you for the PR, left some comments, PTAL

}
return v.charAt(0);
} else if (pojoType.isEnum()) {
return Arrays.stream(pojoType.getEnumConstants())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

getEnumConstants() clones the array and scans on every row. Could build a name -> constant map once at converter creation instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Converter uses static methods ,but i created a map with lazy initialization

return v.charAt(0);
} else if (pojoType.isEnum()) {
return Arrays.stream(pojoType.getEnumConstants())
.filter(e -> e.toString().equals(v.toUpperCase()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works for uppercase enums, but breaks for any enum whose constants aren't all-uppercase (write/read mismatch)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

@@ -0,0 +1,250 @@
/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All the enum tests use an uppercase enum, which is the case that works. Could you add a lowercase enum with a full POJO→Row→POJO round-trip? And ideally a List, so collections hit the same path

@VladBanar VladBanar Jun 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  • adjusted to cover round-trip RowToPojoConverterTest.testConvertTextValueToEnumWithLowercaseInput
  • added lowercase enum
  • added test for an array

() ->
new IllegalArgumentException(
String.format(
"Could not parse value for enum %s. Expected one of: [%s]",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Would it be double brackets here with Arrays.toString?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

@VladBanar VladBanar force-pushed the enum-conversion-functionality-for-typed-writer-reader branch 3 times, most recently from d73cd12 to dcc0d07 Compare June 21, 2026 10:30
@VladBanar VladBanar force-pushed the enum-conversion-functionality-for-typed-writer-reader branch from dcc0d07 to 02e8700 Compare June 21, 2026 10:33
@VladBanar

Copy link
Copy Markdown
Author

@fresh-borzoni Thank you for the review! Addressed the comments PTAL

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.

[client] Add enum conversion functionality for Typed Writer/Reader

2 participants