Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ import org.apache.gluten.extension.injector.Injector
import org.apache.spark.util.SparkReflectionUtil

class VeloxIcebergComponent extends Component {
private val icebergSparkSessionExtension =
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"

override def name(): String = "velox-iceberg"

override def dependencies(): Seq[Class[_ <: Component]] = classOf[VeloxBackend] :: Nil

override def isRuntimeCompatible: Boolean = {
SparkReflectionUtil.isClassPresent(icebergSparkSessionExtension)
SparkReflectionUtil.isClassPresent(
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions")
}

override def sparkSessionExtensions(): Seq[String] = icebergSparkSessionExtension :: Nil

override def injectRules(injector: Injector): Unit = {
OffloadIcebergScan.inject(injector)
OffloadIcebergWrite.inject(injector)
Expand Down
23 changes: 8 additions & 15 deletions gluten-core/src/main/scala/org/apache/gluten/GlutenPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ private[gluten] class GlutenDriverPlugin extends DriverPlugin with Logging {

override def init(sc: SparkContext, pluginContext: PluginContext): util.Map[String, String] = {
val conf = pluginContext.conf()
val components = Component.sorted()
configureSessionExtensions(conf, components)
// Spark SQL extensions
val extensionSeq = conf.get(SPARK_SESSION_EXTENSIONS).getOrElse(Seq.empty)
if (!extensionSeq.toSet.contains(GlutenSessionExtensions.GLUTEN_SESSION_EXTENSION_NAME)) {
conf.set(
SPARK_SESSION_EXTENSIONS,
extensionSeq :+ GlutenSessionExtensions.GLUTEN_SESSION_EXTENSION_NAME)
}
Comment on lines +54 to +59
Comment on lines +54 to +59

setPredefinedConfigs(conf)

val components = Component.sorted()
printComponentInfo(components)
setComponentInfoConfig(conf, components)
components.foreach(_.onDriverStart(sc, pluginContext))
Expand All @@ -71,19 +77,6 @@ private[gluten] class GlutenDriverPlugin extends DriverPlugin with Logging {
}

private object GlutenDriverPlugin extends Logging {
private[gluten] def configureSessionExtensions(
conf: SparkConf,
components: Seq[Component]): Unit = {
val configuredExtensions = conf.get(SPARK_SESSION_EXTENSIONS).getOrElse(Seq.empty)
val requiredExtensions =
components.flatMap(_.sparkSessionExtensions()) :+
GlutenSessionExtensions.GLUTEN_SESSION_EXTENSION_NAME
val mergedExtensions = (configuredExtensions ++ requiredExtensions).distinct
if (mergedExtensions != configuredExtensions) {
conf.set(SPARK_SESSION_EXTENSIONS, mergedExtensions)
}
}

private def checkOffHeapSettings(conf: SparkConf): Unit = {
if (conf.get(GlutenCoreConfig.DYNAMIC_OFFHEAP_SIZING_ENABLED)) {
// When dynamic off-heap sizing is enabled, off-heap mode is not strictly required to be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ trait Component {
def info(): Map[String, String] = Map.empty
def dependencies(): Seq[Class[_ <: Component]]

def sparkSessionExtensions(): Seq[String] = Nil

/** Spark listeners. */
def onDriverStart(sc: SparkContext, pc: PluginContext): Unit = {}
def onDriverShutdown(): Unit = {}
Comment on lines 79 to 84
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,14 @@ abstract class IcebergSuite extends WholeStageTransformerSuite {
.set("spark.memory.offHeap.size", "2g")
.set("spark.unsafe.exceptionOnMemoryLeak", "true")
.set("spark.sql.autoBroadcastJoinThreshold", "-1")
.set(
"spark.sql.extensions",
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions")
.set("spark.sql.catalog.spark_catalog", "org.apache.iceberg.spark.SparkCatalog")
.set("spark.sql.catalog.spark_catalog.type", "hadoop")
.set("spark.sql.catalog.spark_catalog.warehouse", s"file://$rootPath/tpch-data-iceberg-velox")
Comment on lines +40 to 45
}

test("iceberg system procedures are registered by the Gluten plugin") {
spark.sessionState.sqlParser.parsePlan(
"""
|CALL spark_catalog.system.register_table(
| table => 'default.issue_12693',
| metadata_file => 'file:///tmp/does-not-exist.metadata.json'
|)
|""".stripMargin)
}

test("iceberg transformer exists") {
withTable("iceberg_tb") {
spark.sql("""
Expand Down

This file was deleted.