Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MockTaskContext to support new functions added in Spark-4.0 [databricks] #11972

Merged
merged 7 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/dev/shims.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ for conflicting Shim implementations.

### Compile-time issues

#### Methods added in new versions

If the new methods are a superset of functionality from previous versions and can be implemented
nartal1 marked this conversation as resolved.
Show resolved Hide resolved
with default behavior, they can be added directly to the unshimmed class. For methods introduced
in newer versions that do not exist in older versions, removing the override keyword ensures that
these methods are treated as new additions rather than overrides. This allows the same class to work
across different Spark versions.

#### Different parent class signatures

Upstream base classes we derive from might be incompatible in the sense that one version
requires us to implement/override the method `M` whereas the other prohibits it by marking
the base implementation `final`, E.g. `org.apache.spark.sql.catalyst.trees.TreeNode` changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
* Copyright (c) 2020-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,7 @@
*/
package org.apache.spark.sql.rapids.metrics.source

import java.io.Closeable
import java.util
import java.util.Properties

Expand Down Expand Up @@ -102,4 +103,16 @@ class MockTaskContext(taskAttemptId: Long, partitionId: Int) extends TaskContext
* removing the override keyword.
*/
def isFailed(): Boolean = false

/**
* These below methods were introduced in Spark-4. It's not shimmed and added to the common class
* removing the override keyword.
*/

private[spark] def interruptible(): Boolean = false

private[spark] def pendingInterrupt(threadToInterrupt: Option[Thread], reason: String): Unit = {}

private[spark] def createResourceUninterruptibly[T <: Closeable](
resourceBuilder: => T): T = resourceBuilder
}
Loading