Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[FLINK-41780][table] Map element access fails with ClassCastException for a MapData that is neither BinaryMapData nor GenericMapData - #30233

Merged
snuyanzin merged 1 commit into
apache:masterfrom
snuyanzin:flink41780
Dec 2, 2026

Conversation

@snuyanzin

Copy link
Copy Markdown
Contributor

What is the purpose of the change

The PR fixes behavior for the case of MapData that is neither BinaryMapData nor GenericMapData

Brief change log

codegen

Verifying this change

failing test added

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): (no)
  • 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)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Tool Name and Version]

@flinkbot

flinkbot commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

…n` for a `MapData` that is neither `BinaryMapData` nor `GenericMapData`

@rionmonster rionmonster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix overall seems sound/reasonable (I pulled things down and was able to confirm it went red/green as it relates to the fix). I've added a optional proposed test to exercise another path that reproduces the exact same exception.

I'm good with approving, let me know what you think.

.build())
.runSql(
"INSERT INTO sink_t SELECT "
+ "MAP_FROM_ENTRIES(ARRAY[ROW('a', CAST(x AS STRING))])['a'] FROM t")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it would change anything
the reason is that we don't cover anything else in codegen with this test

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.

3 participants