You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2026/08/12 08:19:17 UTC
[PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
cloud-fan opened a new pull request, #57956:
URL: https://github.com/apache/spark/pull/57956
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Followup to https://github.com/apache/spark/pull/57190.
This patch preserves the semantics of variant extractions moved through joins:
- A strict `variant_get` crosses a join only when cast-error deferral is enabled.
- Project attributes above a copied outer join are remapped to the join's actual output so nullable-side attributes retain their widened nullability.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
Moving a strict extraction below a join can evaluate it on rows that the join later eliminates, exposing an error that the original plan would not raise. In addition, copying an outer join widens attributes on its nullable side, while the parent Project could retain references with stale pre-join nullability.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No. This fixes followup issues in an unreleased change on master.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Added regression tests and ran:
```bash
build/sbt 'sql/testOnly org.apache.spark.sql.execution.datasources.PushVariantIntoScanSuite -- -z "left outer join: projected right-side attributes use widened nullability"'
build/sbt 'sql/testOnly org.apache.spark.sql.execution.datasources.PushVariantIntoScanSuite -- -z "strict variant_get crosses a join only with cast-error deferral"'
```
The outer-join nullability test was also verified to fail before the production fix and pass after it.
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
Generated-by: OpenAI Codex (GPT-5).
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #57956:
URL: https://github.com/apache/spark/pull/57956#issuecomment-5318303059
yea the CI failure is unrelated, thanks for review, merging to master/4.x!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3768522520
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
Good point. I replaced the `VariantGet`-specific gate with the generic `Expression.throwable` check. `VariantGet` and `Cast` are not currently classified as throwable, so this preserves the existing behavior for both while making the rule ready to honor that metadata if we classify them in the future. I also removed the new test that singled out strict `variant_get`.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "peter-toth (via GitHub)" <gi...@apache.org>.
peter-toth commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3770985741
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -105,20 +105,10 @@ import org.apache.spark.sql.types.VariantType
* [[SQLConf.PUSH_VARIANT_INTO_SCAN]] is also enabled) and only fires when a hoistable extraction is
* present, so non-variant plans are untouched.
*
- * Cast-error surface: relocating a strict extraction (`variant_get(..., failOnError = true)` or a
- * strict `Cast`) below a `Join` means it is evaluated at the scan on rows the join later eliminates
- * -- so a cast failure can surface for a row the un-hoisted plan would never have cast (here the
- * eliminating rows come from the *other* joined table). This is the same pre-existing trade-off as
- * [[PushVariantIntoScan]] pushing casts below a `Filter`, not a new error class: in both, the
- * strict cast runs before the operator that would have discarded the failing row. This rule only
- * relocates the extraction into a `Project`; [[PushVariantIntoScan]] still does the scan-level
- * materialization and, when [[SQLConf.PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR]] is set (default
- * false), wraps the cast with a per-row cast-error companion slot so the error is only raised when
- * the original expression consumes the failing row. That deferral is provenance-agnostic -- it acts
- * on the relocated extraction regardless of how it reached the `Project` -- so enabling the flag
- * suppresses the join-eliminated-row error exactly as it does the filter-eliminated-row case. With
- * the flag off (the default), the strict cast raises immediately on any failing scanned row, as
- * documented for below-`Filter` pushdown.
+ * Cast-error surface: relocating a throwable extraction below a `Join` means it is evaluated at the
Review Comment:
**Finding 2.** This paragraph states a rule and then withdraws it: "Such extractions cross a join only when [deferral] is enabled", immediately followed by "Expressions not classified as throwable retain the existing behavior, including strict `VariantGet` and `Cast` expressions" -- which is every extraction this rule hoists. Someone coming here for the cast-error contract finds a sentence that applies to nothing.
The paragraph it replaced was written to answer your own review question on #57190, and it is still accurate now that behavior is back to base: it explained *why* relocating a strict extraction below a `Join` is the same accepted trade-off as `PushVariantIntoScan` pushing a cast below a `Filter`, and how `PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR` interacts with it. Deleting it loses the record of that decision, which is the thing a future reader will come looking for. I'd restore it and add a sentence saying the `throwable` check is currently inert and what would make it fire.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -312,7 +311,7 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
}
private def rewriteAggregate(agg: Aggregate): LogicalPlan = {
- val hoister = new ExtractionHoister
+ val hoister = extractionHoister(agg.child.containsPattern(JOIN))
Review Comment:
**Finding 6.** If the gate is ever made live, this isn't quite the right question. `containsPattern(JOIN)` is true for a join anywhere in the subtree, but whether the alias actually crosses a join is decided later, by `pushSideAliases`: when the join sits under a `Filter`, the `case other` arm at `:281` parks the alias in a `Project` above the `Filter` and it never crosses the join -- yet this check classifies it as join-crossing. Same at `rewriteSortUnderProject:390` and `rewriteBareSort:421`.
Not worth changing while the gate is inert, but worth a comment if the machinery is being kept for later.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -442,16 +441,16 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
project: Project, projectList: Seq[NamedExpression], join: Join): LogicalPlan = {
val leftOutput = join.left.outputSet
val rightOutput = join.right.outputSet
- val leftHoister = new ExtractionHoister
- val rightHoister = new ExtractionHoister
+ val leftHoister = extractionHoister(crossesJoin = true)
Review Comment:
**Finding 5.** `crossesJoin = true` has no effect here. `leftHoister`/`rightHoister` are only used via `aliasFor`, `aliases` and `isEmpty` -- never `hoist` -- so the `hoistable` predicate they are constructed with is never consulted. The gating on this path is done inline instead: at `:453` for the join condition and at `:301` inside `hoistProjectListExtractions`.
Passing the predicate reads as if the hoister enforced it, which will mislead the next reader. Either construct plain `new ExtractionHoister` here, or route those two call sites through `hoist` so there is a single place that decides.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -481,7 +480,13 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
left = pushSideAliases(join.left, leftHoister.aliases, needed),
right = pushSideAliases(join.right, rightHoister.aliases, needed),
condition = newCondition)
- project.copy(projectList = newProjectList, child = newJoin)
+ // Outer joins widen attributes on their nullable side. Remap references in the parent
+ // Project to the copied Join's actual output so their nullability matches the child.
+ val newJoinOutput = AttributeMap(newJoin.output.map(attr => attr -> attr))
Review Comment:
**Finding 1.** I measured this one, because it contradicts your own verification on #57190.
**What I ran.** At `c46ec508` I reverted only this remap (back to `project.copy(projectList = newProjectList, child = newJoin)`) and reran `PushVariantIntoScanSuite` and `PushVariantIntoScanV2Suite`: **108 of 110 tests pass, and the only 2 failures are the new test itself** -- it lives in the shared base trait, so it runs once per suite. Its failure is `projectedRightKey.nullable was false` at `PushVariantIntoScanSuite.scala:802`.
I also added a throwaway check over six real SQL queries -- LEFT / RIGHT / FULL OUTER joins, the `Project`-over-`Join` shape, `Sort`-over-`Join` and `Aggregate`-over-`Join` -- asserting that every attribute reference in every node agrees with that child's output on nullability, evaluated on the analyzed plan, on this rule's own output, and on the fully optimized plan. With the remap reverted: zero violations on all six, including the direct SQL analogue of the new test, `select d.k, variant_get(d.data, '$.label', 'string') from SS ss left join DIM d on ss.k = d.k`.
**Why there is nothing to fix.** No alias this rule creates can be non-nullable, so the outer join's widening has nothing to widen: `VariantGet.nullable` is `true` unconditionally (`variantExpressions.scala:446`), and `Cast.nullable` is `child.nullable || Cast.forceNullable(...)` (`Cast.scala:773`) with `Cast.forceNullable(VariantType, _) = true` (`Cast.scala:551`). And `pushSideAliases` only adds and drops columns, never rebuilding a retained attribute, so `newJoin.output` agrees with `join.output` on nullability for everything `newProjectList` references.
That is the conclusion your #57190 review already recorded: "`VariantGet.nullable` and `Cast(VariantType->_)` are always `nullable=true`, and `Join.computeOutput` widens the null-supplying side to nullable, so every parent reference to a pushed `_ve` is nullable-over-nullable (AGREES) -- no plan-integrity nullability mismatch." I think that reading was right.
**On the test** (`PushVariantIntoScanSuite.scala:796`). It builds `Project(Seq(rightKey /* nullable = false */, ...), <LeftOuter join>)`. The analyzer resolves a `Project`'s references against `child.output`, and `Join.computeOutput` maps the nullable side through `withNullability(true)` (`basicLogicalOperators.scala:703`), so a `Project` above a `LeftOuter` join never holds the pre-widening `rightKey`. I don't doubt "verified to fail before the production fix and pass after it" -- it does fail. It fails because the test constructs the inconsistency itself, which is why it isn't evidence of a defect.
So either there is a plan shape I haven't found -- in which case a test on a real query would be worth far more than this one -- or the remap is normalization rather than a fix. If it's normalization I don't object to keeping the code, but I'd drop or relabel the test and the description claim: as written, someone will later read this as a shipped bug fix and may backport it to branch-4.3 / branch-4.x for nothing. And if it is kept, the same normalization is missing in the sibling paths -- `rewriteAggregate`'s `newAggExprs`, `newOrder` in both `Sort` paths, and `pushSideAliases:275` -- which makes the intent hard to read.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #57956:
URL: https://github.com/apache/spark/pull/57956#issuecomment-5318318731
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/b94bbfb27b825ef684814402e77f4d78a83cfc1b
- merged into branch-4.x https://github.com/apache/spark/commit/b484171fa9ac59bb05df21c08f28f2e3c55e5058
*Posted by `merge_spark_pr.py`*
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3796860083
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
Yes, `PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR` is intentional here. Unlike `CombineFilters` and `PushPredicateThroughJoin`, scan pushdown has a per-row cast-error companion column that preserves the original evaluation point. A throwable extraction can therefore safely cross a join when deferral is enabled; without deferral, the rule stops hoisting it across the join.
I documented this distinction beside `isJoinHoistable` and expanded the config description in a12124e39a5. I also added the suggested test pinning hoistable `VariantGet` and `Cast` as non-throwable. The focused test passed in all four V1/V2 reader suites.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3768326619
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
Is there a reason to add this new gate? isJoinHoistable gate will not hoist a strict variant_get across a Join unless PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR is set. The ungated behavior is documented between line 108-122, and is more consistent with existing bahaviors. It seems this gate singles out variant for cross a join while allowing the two cases to raise:
1. variant_get below a Filter → raises
2. cast(v as int) across a Join → raises (test @844, pre-existing base-PR behavior)
3. variant_get across a Join → suppressed by the gate (test @881, new here)
Remove the gate ensures all three have consistent behavior. We also have existing switches:
- pushVariantIntoScan.pullOutExtractions = false to turn off the pull-out rule completely
- pushVariantIntoScan.deferCastError = true to defer the error past eliminated rows uniformly for every strict extraction
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -481,7 +494,13 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
left = pushSideAliases(join.left, leftHoister.aliases, needed),
right = pushSideAliases(join.right, rightHoister.aliases, needed),
condition = newCondition)
- project.copy(projectList = newProjectList, child = newJoin)
+ // Outer joins widen attributes on their nullable side. Remap references in the parent
+ // Project to the copied Join's actual output so their nullability matches the child.
Review Comment:
+1 on nullablity fix
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #57956: [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics
URL: https://github.com/apache/spark/pull/57956
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "peter-toth (via GitHub)" <gi...@apache.org>.
peter-toth commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3784989041
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
**Finding 4.** Fair enough, keeping `throwable` makes sense.
The one item left from this thread is @qlong's test. Both other `throwable` callers pin their classification the same way — `assert(!arithmetic.throwable)` at `ExprUtilsSuite.scala:44` and `assert(!unmarkedThrowable.throwable)` at `SplitStreamedSideJoinConditionSuite.scala:115` — each beside a comment saying what the assertion protects:
```scala
test("hoistable variant extractions are not classified as throwable") {
// `isJoinHoistable`'s join gate is inert while this holds. Classifying either expression as
// throwable stops this rule hoisting extractions across a Join unless
// spark.sql.variant.pushVariantIntoScan.deferCastError is set.
val v = AttributeReference("v", VariantType)()
assert(!VariantGet(v, Literal("$.a"), IntegerType, failOnError = true, Some("UTC")).throwable)
assert(!Cast(v, IntegerType, Some("UTC")).throwable)
}
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3786435123
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
One more on this gate. When e.throwable becomes true in the future, is PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR the right gate?
1. For both CombineFilers and PushPredicateThroughJoin, they stop when throwable is true. But here it would continue to hoist if PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR is true.
2. If we decide to continue use PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR as the gate, we need change its doc when e.throwable is turee.
Nonblocking, but I think we should add a comment here, or drop the check on PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR and design the right switch when e.throwable is true.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on PR #57956:
URL: https://github.com/apache/spark/pull/57956#issuecomment-5297106595
Thanks @cloud-fan and @peter-toth . I left a non-blocking comment for the isJoinHoistable
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3786435123
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
One more on this gate. When e.throwable becomes true in the future, is PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR the right gate?
1. For both CombineFilers and PushPredicateThroughJoin, they stop when throwable is true. But here it would continue to hoist if PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR is true.
2. If we decide to continue use PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR as the gate, we need change its doc when e.throwable is turee.
Nonblocking, but I think we should add a comment here, or drop the check on PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "peter-toth (via GitHub)" <gi...@apache.org>.
peter-toth commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3770989619
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
**Finding 4.** @qlong's worry that there'd be no signal if `Cast`/`VariantGet` get classified as throwable later is well founded, and I think there's a sharper version of it: the flag isn't this rule's to define. `CombineFilters` (`Optimizer.scala:2039`) and `PushPredicateThroughJoin` (`:2475`, `:2507`) both branch on `!cond.throwable`, so nobody can set `Cast.throwable = true` or `VariantGet.throwable = true` in order to activate this gate -- that would change filter merging and join-condition pushdown for every query at the same time. So the hook can't really be honored on purpose for variant shredding, and in the other direction, if the flag is ever flipped for an unrelated reason this rule silently stops shredding across joins as a side effect. `ExprUtils.scala:244-246` records a similar reservation for a different caller: "this deliberately does not rely on `Expression.throwable`, which is opt-in metadata that most expressions do not override."
That makes @qlong's suggested test worth more than a minor nit, and I'd also add a comment next to `isJoinHoistable` saying the check is inert today and what would make it fire, because right now it reads as a live guard. For the record on how inert it is: `throwable` defaults to `children.exists(_.throwable)` (`Expression.scala:169`) and `Sequence` (`collectionOperations.scala:3479`) is the only override in all of `sql/`, while `isHoistable` only admits an `Attribute`/`GetStructField` chain plus foldable `Literal`s -- so `isJoinHoistable` is currently exactly `isHoistable`.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3768326619
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
Is there a reason to add this new gate? isJoinHoistable gate will not hoist a strict variant_get across a Join unless PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR is set. The ungated behavior is documented between line 108-122, and is more consistent with existing bahaviors. It seems this gate singles out variant for cross a join while allowing the other two cases to raise:
1. variant_get below a Filter → raises
2. cast(v as int) across a Join → raises (test @844, pre-existing base-PR behavior)
3. variant_get across a Join → suppressed by the gate (test @881, new here)
Remove the gate ensures all three have consistent behavior. We also have existing switches:
- pushVariantIntoScan.pullOutExtractions = false to turn off the pull-out rule completely
- pushVariantIntoScan.deferCastError = true to defer the error past eliminated rows uniformly for every strict extraction
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #57956:
URL: https://github.com/apache/spark/pull/57956#issuecomment-5268404312
LGTM
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3768326619
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
Is there a reason to add this new gate? isJoinHoistable gate will not hoist a strict variant_get across a Join unless PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR is set. The ungated behavior is documented between line 108-122, and is more consistent with existing bahaviors. It seems this gate singles out variant for cross a join while allowing the other two cases to raise:
1. variant_get below a Filter → raises
2. cast(v as int) across a Join → raises (test @844, pre-existing base-PR behavior)
3. variant_get across a Join → suppressed by the gate (test @881, new here)
I think it's good that all three have consistent behavior. We also have existing switches:
- pushVariantIntoScan.pullOutExtractions = false to turn off the pull-out rule completely
- pushVariantIntoScan.deferCastError = true to defer the error past eliminated rows uniformly for every strict extraction
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #57956:
URL: https://github.com/apache/spark/pull/57956#issuecomment-5264252414
cc @qlong @peter-toth
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3784612400
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
I disagree with the characterization that `throwable` is not this rule's flag to use.
`Expression.throwable` is the standard expression-level contract for optimizer transformations
that may change whether an expression is evaluated and therefore whether an exception is
observable. The fact that `CombineFilters` and `PushPredicateThroughJoin` also respect it is
intentional: if an expression is classified as throwable, all rules that can change its evaluation
semantics should react consistently rather than maintaining rule-specific classifications.
It is true that the check does not change behavior for today's hoistable `VariantGet` and `Cast`
expressions, but that makes it forward-looking rather than conceptually inert. I updated the class
documentation to state the current classification and the behavior if an extraction becomes
throwable. I also addressed the separate implementation concerns in 82ad6dbcfcf: join crossing now
mirrors actual alias placement through pass-through Projects, and the unused hoister predicate in
the direct Join path is gone.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3786435123
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
One more on this gate. When e.throwable becomes true in the future, is PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR the right gate?
1. For both CombineFilers and PushPredicateThroughJoin, they stop when throwable is true. But here it would continue to hoist if PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR is true.
2. If we decide to continue use PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR as the gate, we should change its doc when e.throwable is turee.
Nonblocking, but I think we should add a comment here, or drop the check on PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3768326619
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
Is there a reason to add this new gate? isJoinHoistable gate will not hoist a strict variant_get across a Join unless PUSH_VARIANT_INTO_SCAN_DEFER_CAST_ERROR is set. The ungated behavior is documented between line 108-122, and is more consistent with existing bahaviors. It seems this gate singles out variant for cross a join while allowing the other two cases to raise:
1. variant_get below a Filter → raises
2. cast(v as int) across a Join → raises (test @844, pre-existing base-PR behavior)
3. variant_get across a Join → suppressed by the gate (test @881, new here)
I think it good that l three have consistent behavior. We also have existing switches:
- pushVariantIntoScan.pullOutExtractions = false to turn off the pull-out rule completely
- pushVariantIntoScan.deferCastError = true to defer the error past eliminated rows uniformly for every strict extraction
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3768894997
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
+1 on using throwable, it is cleaner. Minor suggestion, please feel free to ignore. I am a bit worried there is no clear signal for hoist behavior change when someone classifies Cast and VariantGet as throwable in the future. Should we add a unit test to assert those two never throw and add some comment there?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-58089][SQL][FOLLOWUP] Preserve join extraction semantics [spark]
Posted by "qlong (via GitHub)" <gi...@apache.org>.
qlong commented on code in PR #57956:
URL: https://github.com/apache/spark/pull/57956#discussion_r3768894997
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PullOutVariantExtractions.scala:
##########
@@ -177,11 +177,20 @@ object PullOutVariantExtractions extends Rule[LogicalPlan] {
case _ => false
}
+ private def isJoinHoistable(e: Expression): Boolean = {
Review Comment:
+1 on using throwable, it is cleaner. Minor suggestion, please feel free to ignore. I am a bit worried there is no clear signal for hoist behavior change when someone classifies Cast and VariantGet as throwable in the future. Should we add a unit test to assert those two are throwable and add some comment there?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org