hulincup commented on code in PR #28931:
URL: https://github.com/apache/flink/pull/28931#discussion_r3817988490
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/StringFunctionsITCase.java:
##########
@@ -182,6 +186,26 @@ private Stream<TestSetSpec> eltTestCases() {
DataTypes.VARCHAR(5))
.testResult(
lit(2).elt("a", "b"), "ELT(2, 'a', 'b')", "b",
DataTypes.CHAR(1))
+ .testResult(
+ lit(2).cast(DataTypes.TINYINT()).elt("scala",
"java"),
+ "ELT(CAST(2 AS TINYINT), 'scala', 'java')",
+ "java",
+ DataTypes.VARCHAR(5))
+ .testResult(
+ $("f4").elt("scala", "java"),
+ "ELT(f4, 'scala', 'java')",
+ "java",
+ DataTypes.VARCHAR(5))
+ .testResult(
Review Comment:
Good question — honest answer: not interactively in the sqlclient. My local
environment only has JDK 8, so I can't build/run Flink's sqlclient here; I've
been relying on the ITCase + CI.
That said, these null cases do exercise the runtime rather than getting
folded at plan time: the index/expr are field references (`f0`, `f1`, `f2`,
`f4`) loaded with null data via `onFieldsWithData`, so `ExpressionReducer`
can't constant-fold them and the `ELT` call reaches the codegen'd operator —
the same path sqlclient would hit. `EltFunction.eval` returns null explicitly
for `index == null` and out-of-range, and returns the (possibly null) selected
expr otherwise, so all three null shapes (null index, null expr at selected
position, null expr at unselected position) are covered. Since
`StringFunctionsITCase` runs the query through the full runtime, it's
effectively the same verification as running it in sqlclient.
If there's a specific sqlclient shape you'd like confirmed (e.g. literal
`NULL` index or `CAST(NULL AS …)` exprs), I can spin up a JDK 17 + Flink binary
and capture the actual output — happy to do that.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]