Skip to content

[spark] prepare MAP selected-key pushdown read type#8478

Merged
JingsongLi merged 8 commits into
apache:masterfrom
lszskye:recall_specific_key_in_map
Jul 9, 2026
Merged

[spark] prepare MAP selected-key pushdown read type#8478
JingsongLi merged 8 commits into
apache:masterfrom
lszskye:recall_specific_key_in_map

Conversation

@lszskye

@lszskye lszskye commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Purpose

This PR introduces the preliminary Spark-side and metadata infrastructure for MAP selected-key pushdown.
The target use case is to allow upper engines, such as Spark, to describe a read schema like:

SELECT id, attrs['key1'] AS key1_value, attrs['key2'] AS key2_value FROM T;

as a temporary Paimon read type where the MAP field is rewritten to a ROW field, and the selected MAP keys are recorded in DataField.description:

__PAIMON_MAP_SELECTED_KEYS:key1;key2

This metadata is only intended to exist in the temporary scan/read schema. It must not be persisted into table schema or catalog schema.

Explicitly out of scope

This PR does not enable the full read path yet. The following parts are intentionally left for a follow-up PR for #8392 is not merged:

  • FormatReaderMapping support for consuming __PAIMON_MAP_SELECTED_KEYS.
  • Core reader support for reading a MAP field as a rewritten ROW field.
  • Shared-shredding MAP reader support for selected-key recall.
  • End-to-end SQL execution for attrs['key1'] / element_at(attrs, 'key1') selected-key pushdown.
    Because the reader/core side is not implemented in this PR, the optimizer rule is not registered in PaimonSparkSessionExtensions.

Tests

MAP selected-key metadata construction and parsing.
Empty key handling.
Duplicate selected-key validation.
Spark read type rewrite behavior for selected MAP keys.

@JingsongLi

Copy link
Copy Markdown
Contributor

The optimizer rule is not registered in PaimonSparkSessionExtensions yet (there is only a TODO), so pushedMapSelectedKeys is never populated and the advertised Spark pushdown is not actually enabled. Could you either register the rule together with the reader support, or adjust the PR/title to make this explicitly preparatory? Also, when the rule is enabled, unsupported cases such as nested shared-shredding maps or literal keys containing the metadata delimiter should fall back without pushdown instead of failing a valid query during planning.

@lszskye lszskye changed the title [spark] Support map selected keys read type pushdown [spark] Prepare MAP selected-key pushdown read type Jul 7, 2026
@lszskye lszskye changed the title [spark] Prepare MAP selected-key pushdown read type [spark] prepare MAP selected-key pushdown read type Jul 7, 2026
@lszskye

lszskye commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

The optimizer rule is not registered in PaimonSparkSessionExtensions yet (there is only a TODO), so pushedMapSelectedKeys is never populated and the advertised Spark pushdown is not actually enabled. Could you either register the rule together with the reader support, or adjust the PR/title to make this explicitly preparatory? Also, when the rule is enabled, unsupported cases such as nested shared-shredding maps or literal keys containing the metadata delimiter should fall back without pushdown instead of failing a valid query during planning.

Sure, thanks for pointing this out.
Since Xinyu’s changes for the read/write framework have not been merged yet, I don’t plan to enable the actual reader path in this PR. I’ll follow your suggestion and update the PR title/description to make it clear that this is preparatory work rather than an enabled end-to-end pushdown feature.
Also unsupported cases such as nested shared-shredding maps is fixed

@lszskye lszskye requested a review from JingsongLi July 8, 2026 08:53

@JingsongLi JingsongLi 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.

+1

@JingsongLi JingsongLi merged commit 5c3d4bc into apache:master Jul 9, 2026
12 checks passed
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.

2 participants