Skip to content

Conversation

@hemanthsavasere
Copy link
Contributor

@hemanthsavasere hemanthsavasere commented Oct 28, 2025

Purpose

Linked issue: close #1844

Perform automatic type widening between numeric types when converting POJOs to internal rows. Change from strict and exact type validation to widening conversion from lower to higher data types in POJO field's Java type and the schema's Fluss type.

Implementation Sample Scenarios :
POJO with int field + Schema with BIGINT → SUCCEEDS ✅
POJO with short field + Schema with BIGINT → SUCCEEDS ✅
POJO with int field + Schema with FLOAT → SUCCEEDS ✅
POJO with Long field + Schema with SMALLINT → FAILS (narrowing not supported) ❌

Widening Primitive Conversions :
byte (TINYINT) → short, int, long, float, double
short (SMALLINT) → int, long, float, double
int (INTEGER) → long, float, double
long (BIGINT) → float, double
float (FLOAT) → double

fluss-client

  1. Expanded SUPPORTED_TYPES map in ConverterCommons.java to include all widening-compatible source types for each numeric target type
  2. Added casting logic in PojoToRowConverter.java with dedicated conversion methods for each numeric type (convertToTinyInt, convertToSmallInt, convertToInteger, convertToBigInt, convertToFloat, convertToDouble)

fluss-flink-common

  1. Updated SUPPORTED_TYPES map in PojoToRowConverter.java to include widening-compatible types (both primitives and boxed)
  2. Implemented casting logic in createConverterForField() method with corresponding conversion helper methods

Tests

Added comprehensive tests in PojoToRowConverterTest.java for all widening combinations in fluss-client
Added comprehensive tests in PojoToRowConverterTest.java covering all widening scenarios in fluss-flink-common

@hemanthsavasere
Copy link
Contributor Author

@polyzos Can you please review the pull request. Thanks

@polyzos
Copy link
Contributor

polyzos commented Oct 29, 2025

@hemanthsavasere can you remove the documentation? This functionality is meant for internal use.
The goal is to update the existing Java client to use this functionality under the hood so it's transparent to the users.
So we don't need to document it, as it won't be exposed to users directly

@polyzos
Copy link
Contributor

polyzos commented Oct 29, 2025

@snuyanzin thank you for reviewing this and your thoughtful feedback

@hemanthsavasere hemanthsavasere marked this pull request as draft November 22, 2025 16:14
@hemanthsavasere
Copy link
Contributor Author

@snuyanzin and @polyzos I have done the changes, can you please review PR.

@hemanthsavasere hemanthsavasere marked this pull request as ready for review November 23, 2025 17:10
@hemanthsavasere
Copy link
Contributor Author

@snuyanzin @polyzos I have completed the requested changes. When you have the opportunity, could you please review the PR?

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.

Relax conditions for converters

3 participants