rionmonster commented on code in PR #30233:
URL: https://github.com/apache/flink/pull/30233#discussion_r4771896463
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/common/CalcTestPrograms.java:
##########
@@ -816,4 +816,23 @@ private static SinkTestStep stringSink(final String name,
final Row... rows) {
+ REUSED
+ ") x JOIN t y ON x.s = y.s")
.build();
+
+ public static final TableTestProgram CALC_MAP_ITEM_ACCESS =
+ TableTestProgram.of(
+ "calc-map-item-access",
+ "validates map element access over a non-generic
MapData")
+ .setupTableSource(
+ SourceTestStep.newBuilder("t")
+ .addSchema("x INT")
+ .producedValues(Row.of(1))
+ .build())
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema("v STRING")
+ .consumedValues(Row.of("1"))
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "MAP_FROM_ENTRIES(ARRAY[ROW('a', CAST(x
AS STRING))])['a'] FROM t")
Review Comment:
As far as I can tell, this should fix the function-returned map case (since
the previous deep-copy version fails as expected). I pulled some threads and I
think it could be useful to exercise a case where we receive a map as an input
column. Claude seemed to think we could add this to `ParquetFileSystemITCase`
which passes (and fails with the exact `ColumnarMapData cannot be cast to
GenericMapData,` exception before this fix):
```
@TestTemplate
void testMapElementAccess() throws Exception {
String path =
TempDirUtils.newFolder(super.fileTempFolder()).toURI().getPath();
super.tableEnv()
.executeSql(
String.format(
"create table map_t ("
+ "id int,"
+ "m map<string, string>"
+ ") with ("
+ "'connector' = 'filesystem',"
+ "'path' = '%s',"
+ "'format' = 'parquet'"
+ ")",
path));
super.tableEnv()
.executeSql("insert into map_t values (1, map['a', 'x']), (2,
map['b', 'y'])")
.await();
// the map reaches the Calc as ColumnarMapData; the second row covers a
missing key
check(
"select id, m['a'] from map_t",
Arrays.asList(Row.of(1, "x"), Row.of(2, null)));
}
```
Thoughts on that? If that's overkill, then would it be worth including this
same program in the batch suite of tests in `CalcBatchSemanticTests`
--
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]