Skip to content

[spark] Do not merge scalar subqueries that read different columns of a query-auth table - #11427

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:spark-merge-subqueries-query-auth
Open

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:spark-merge-subqueries-query-auth

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Fixes #11426.

MergePaimonScalarSubqueries merges two scans of a Paimon table that differ only in the columns they read into one scan over both sets of columns. For a table with query-auth.enabled, the scan sends the columns it reads to the catalog's authTableQuery, which returns the row filters and column masks for those columns. A merged scan asks about the union of columns, whose rules need not match what each subquery would get. Spark 3.3 to 4.3 run this rule.

With this PR, mergePaimonScan no longer merges such scans when the table's options enable query auth. Scans that read the same columns still merge. The check sees the option whether it comes from the table, a spark.paimon.* session config or a read option.

On 4.3, #11425 replaces the rule with Spark's own scan merging, which keeps query-auth tables out unless only a read option enables it.

Tests

MergeScalarSubqueriesQueryAuthTestBase in paimon-spark-ut runs against the REST catalog test server, with a subclass in each of the 3.3 to 4.2 modules:

  • Subqueries that read different columns become one scan without query auth and two scans when the table property, the session config or a read option enables it.
  • Subqueries that read the same column of a query-auth table still become one scan. On 3.3 to 4.0 only mergePaimonScan merges identical Paimon scans, so this case fails if the check moves above the equality test.
  • The read-option case is skipped when the table declares SCAN_MERGING, which it does on Spark 4.3 after [spark] Let Spark 4.3 merge scalar subqueries over Paimon tables #11425.

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.

[Bug] [spark] MergePaimonScalarSubqueries merges scans of a query-auth table that read different columns

1 participant