Keep the TableCacheQueryStageExec on the CPU but convert the child plan - #13944
Keep the TableCacheQueryStageExec on the CPU but convert the child plan#13944razajafri wants to merge 6 commits into
Conversation
…ting partition count in GpuOptimizeWriteExchangeExec (NVIDIA#13804) Backport of NVIDIA#13780. Cherry picked from commit f02e77d. ### Description `GpuOptimizeWriteExchangeExec` computes the `actualNumPartitions` based on the partition count of its input. The computed `actualNumPartitions` is used to dynamically optimize the partitioning. This logic is currently missing handling of the case when the input partition count is 0, which can cause the ArithmeticException error. This PR adds a proper handling of the case. ### Checklists - [ ] This PR has added documentation for new or modified features or behaviors. - [x] This PR has added new tests or modified existing tests to cover new code paths. (Please explain in the PR description how the new code paths are tested, such as names of the new/existing tests that cover them.) - [ ] Performance testing has been performed and its results are added in the PR description. Or, an issue has been filed with a link in the PR description. Signed-off-by: Jihoon Son <ghoonson@gmail.com>
…VIDIA#13782) This is a cherry-pick of NVIDIA#13775 for 25.10. ### Description The PR is a clean cherry-pick of a commit we are adding in 25.12 to circumvent an exception in the state machine. See NVIDIA#13774 for more info. ### Checklists - [x] This PR has added documentation for new or modified features or behaviors. - [ ] This PR has added new tests or modified existing tests to cover new code paths. (Please explain in the PR description how the new code paths are tested, such as names of the new/existing tests that cover them.) - [ ] Performance testing has been performed and its results are added in the PR description. Or, an issue has been filed with a link in the PR description. Signed-off-by: Alessandro Bellina <abellina@nvidia.com>
…DIA#13831) This cherry picks NVIDIA#13806 to 25.10 - [ ] This PR has added documentation for new or modified features or behaviors. - [ ] This PR has added new tests or modified existing tests to cover new code paths. (Please explain in the PR description how the new code paths are tested, such as names of the new/existing tests that cover them.) - [ ] Performance testing has been performed and its results are added in the PR description. Or, an issue has been filed with a link in the PR description. --------- Signed-off-by: Alessandro Bellina <abellina@nvidia.com>
Signed-off-by: Raza Jafri <raza.jafri@gmail.com>
Greptile OverviewGreptile SummaryThis PR attempts to fix a bug where writing to a Delta table after caching Parquet scan results throws a
Critical Issue: The new handler appears to be unreachable for Confidence Score: 2/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant AQE as AdaptiveQueryExec
participant OAT as optimizeAdaptiveTransitions
participant TCQS as TableCacheQueryStageExec
participant IMTS as InMemoryTableScanExec
AQE->>OAT: Process plan with TableCacheQueryStageExec
OAT->>OAT: Match case at line 177-179<br/>(getTableCacheNonQueryStagePlan.nonEmpty)
OAT->>TCQS: Get children (returns wrapped plan)
OAT->>OAT: Recursively process child<br/>InMemoryTableScanExec
Note over OAT: New handler at line 245-249<br/>is never reached for TCQS
OAT->>TCQS: withNewChildren(optimized children)
TCQS-->>AQE: Return modified TCQS
|
|
build |
revans2
left a comment
There was a problem hiding this comment.
I still don't totally understand what is happening that caused this to be a problem, but making sure that the cached table wrapper stays on the CPU is confusing. Do we end up converting the data to and from the CPU around it?
Could we make sure that we test this on databricks, because you did not update the shims for databricks.
| df2 = unary_op_df(spark, data_gen).withColumnRenamed("a", "r_a").cache() | ||
| df1.count() | ||
| df2.count() | ||
| return df1.join(df2, df1.a == df2.r_a, 'Outer') |
There was a problem hiding this comment.
nit: I don't think that a and r_a will ever be equal. At least statistically it should be fairly rare.
| @ignore_order(local=True) | ||
| @allow_non_gpu("CollectLimitExec", "ShuffleExchangeExec", "ColumnarToRowExec") | ||
| @pytest.mark.parametrize('enable_vectorized_conf', enable_vectorized_confs, ids=idfn) | ||
| @allow_non_gpu_conditional(is_spark_350_or_351(), "InMemoryTableScanExec") |
There was a problem hiding this comment.
Is there a follow on issue for the cache not being on the GPU?
| ).persist(StorageLevel.MEMORY_AND_DISK) | ||
| minNbrs1.count() | ||
|
|
||
| ee.join(minNbrs1, "src") |
There was a problem hiding this comment.
This is a noop and should be deleted
|
|
||
| override def handleTableCacheInOptimizeAdaptiveTransitions(plan: SparkPlan, | ||
| parent: Option[SparkPlan]): Option[SparkPlan] = { | ||
| plan match { |
There was a problem hiding this comment.
So effectively we are saying for Spark 3.5.0+ (non-DB) don't do into TableCacheQueryStageExec? It is already handled.
There was a problem hiding this comment.
Additional Comments (1)
-
sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuTransitionOverrides.scala, line 245-249 (link)logic: The new
handleTableCacheInOptimizeAdaptiveTransitionscall appears to be unreachable forTableCacheQueryStageExecbecause line 177-179 already matches it first:// Line 177-179 (earlier in the match): case p if SparkShimImpl.getTableCacheNonQueryStagePlan(p).nonEmpty => p.withNewChildren(p.children.map(c => optimizeAdaptiveTransitions(c, Some(p))))
Both
getTableCacheNonQueryStagePlanandhandleTableCacheInOptimizeAdaptiveTransitionsmatchTableCacheQueryStageExec, so the earlier case wins.If the goal is to prevent child processing for
TableCacheQueryStageExec, the handler should be placed before line 177, or line 177-179 should be modified to use the new shim method's behavior.
3 files reviewed, 1 comment
|
Please please up-merge to HEAD of release/25.12 |
|
This is not needed as the bug is not reproducible in 25.10+ |
Fixes #13878
Description
A customer has reported a bug where writing to a Delta table after caching Parquet scan results in an exception. The fix keeps the
TableCacheQueryStageExecon the CPU but brings the child planInMemoryTableScanExecon the GPU.Checklists
(Please explain in the PR description how the new code paths are tested, such as names of the new/existing tests that cover them.)