raminqaf opened a new pull request, #26862: URL: https://github.com/apache/flink/pull/26862
## What is the purpose of the change This pull request fixes a code generation compilation error that occurs when using the `ROW()` function with `CAST()` to `SMALLINT` or `TINYINT` types on non-literal input expressions. The issue was in the `primitiveDefaultValue()` method in `CodeGenUtils.scala`, which was generating untyped integer literals (`"-1"`) for both `TINYINT` and `SMALLINT` types, causing Java compilation failures when these values were passed to methods expecting properly typed parameters (e.g., `BinaryRowWriter.writeShort(int, short)`). ## Brief change log - Modified `primitiveDefaultValue()` method in `CodeGenUtils.scala` to return properly typed literals for `TINYINT` and `SMALLINT` - Changed `TINYINT` default value from `"-1"` to `"((byte) -1)"` - Changed `SMALLINT` default value from `"-1"` to `"((short) -1)"` - Added comprehensive unit tests for `primitiveDefaultValue()` method including parameterized tests for all primitive types - Added integration tests to verify the fix works with `ROW()` and `CAST()` operations ## Verifying this change This change added tests and can be verified as follows: - *Added parameterized unit tests in `CodeGenUtilsTest.scala` that verify `primitiveDefaultValue()` returns correctly typed literals for all primitive types* - *Added compilation validation tests that ensure the generated default values compile as valid Java code when used in method calls* - *Added integration test in `RowFunctionITCase.java` that reproduces the original failure scenario: `SELECT ROW(CAST(SCORE AS SMALLINT)) FROM (VALUES (1)) AS T(SCORE)`* - *Added tests for both `SMALLINT` and `TINYINT` casting scenarios to ensure both types are fixed* - *Added tests that verify consistency between `primitiveDefaultValue()` and `primitiveLiteralForType()` methods* - *Manually verified the fix by running the original failing SQL query that triggered the compilation error* ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): no - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no - The serializers: no - The runtime per-record code paths (performance sensitive): yes - this affects code generation for primitive type handling in ROW functions - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no - The S3 file system connector: no ## Documentation - Does this pull request introduce a new feature? no - If yes, how is the feature documented? not applicable - this is a bug fix -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org