You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
changed the title
[spark] Support map selected keys read type pushdown
[spark] Prepare MAP selected-key pushdown read type
Jul 7, 2026
lszskye
changed the title
[spark] Prepare MAP selected-key pushdown read type
[spark] prepare MAP selected-key pushdown read type
Jul 7, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;key2This 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:
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.