-
Notifications
You must be signed in to change notification settings - Fork 14k
[FLINK-40338][table-runtime] ELT() throws ClassCastException when index is not INT #28931
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,6 +182,22 @@ private Stream<TestSetSpec> eltTestCases() { | |
| DataTypes.VARCHAR(5)) | ||
| .testResult( | ||
| lit(2).elt("a", "b"), "ELT(2, 'a', 'b')", "b", DataTypes.CHAR(1)) | ||
| // FLINK-40338: non-INT INTEGER_NUMERIC index must not throw ClassCastException | ||
| .testResult( | ||
| lit(2).cast(DataTypes.TINYINT()).elt("scala", "java"), | ||
| "ELT(CAST(2 AS TINYINT), 'scala', 'java')", | ||
| "java", | ||
| DataTypes.VARCHAR(5)) | ||
| .testResult( | ||
| lit(2).cast(DataTypes.SMALLINT()).elt("scala", "java"), | ||
| "ELT(CAST(2 AS SMALLINT), 'scala', 'java')", | ||
| "java", | ||
| DataTypes.VARCHAR(5)) | ||
| .testResult( | ||
| lit(2).cast(DataTypes.BIGINT()).elt("scala", "java"), | ||
| "ELT(CAST(2 AS BIGINT), 'scala', 'java')", | ||
| "java", | ||
| DataTypes.VARCHAR(5)) | ||
|
Comment on lines
+186
to
+200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for picking this up, the fix itself looks right. One coverage gap worth closing before merge. All three new cases pass constant arguments, so To be clear, these cases do fail without the fix, because the reducer executes the function at plan time. But they only cover the constant-folding path, not the codegen'd operator path that a real job hits, so a future regression in the runtime path wouldn't be caught here. The case just below at line 201 already uses the field-reference pattern, so extending the existing fields covers it: .onFieldsWithData(null, null, null, new byte[] {1, 2, 3}, (byte) 2, (short) 2, 2L)
.andDataTypes(
DataTypes.INT(), DataTypes.STRING(), DataTypes.BYTES(), DataTypes.BYTES(),
DataTypes.TINYINT(), DataTypes.SMALLINT(), DataTypes.BIGINT())and then I'm the reporter of FLINK-40338 and already have these written and verified locally (they fail with
Comment on lines
+186
to
+200
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just in case write a test with non-literals too please There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @raminqaf agreed. Here's the patch I have locally, already verified, it fails with .onFieldsWithData(null, null, null, new byte[] {1, 2, 3}, (byte) 2, (short) 2, 2L)
.andDataTypes(
DataTypes.INT(), DataTypes.STRING(), DataTypes.BYTES(), DataTypes.BYTES(),
DataTypes.TINYINT(), DataTypes.SMALLINT(), DataTypes.BIGINT()).testResult(
$("f4").elt("scala", "java"),
"ELT(f4, 'scala', 'java')",
"java",
DataTypes.VARCHAR(5))
.testResult(
$("f5").elt("scala", "java"),
"ELT(f5, 'scala', 'java')",
"java",
DataTypes.VARCHAR(5))
.testResult(
$("f6").elt("scala", "java"),
"ELT(f6, 'scala', 'java')",
"java",
DataTypes.VARCHAR(5))@hulincup feel free to take these directly. |
||
| .testResult( | ||
| lit(2).elt($("f2"), $("f3"), $("f3")), | ||
| "ELT(2, f2, f3, f3)", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this