Skip to content

Commit

Permalink
add isStaticConfigKey to adapt Spark-3.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cfmcgrady committed Apr 7, 2023
1 parent 22cc70f commit 8280783
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.engine.spark.{SparkSQLEngine, WithSparkSQLEngine}
import org.apache.kyuubi.engine.spark.session.SparkSessionImpl
import org.apache.kyuubi.operation.SparkDataTypeTests
import org.apache.kyuubi.reflection.DynFields

class SparkArrowbasedOperationSuite extends WithSparkSQLEngine with SparkDataTypeTests {

Expand Down Expand Up @@ -406,7 +407,7 @@ class SparkArrowbasedOperationSuite extends WithSparkSQLEngine with SparkDataTyp
}
}
(keys, values).zipped.foreach { (k, v) =>
if (SQLConf.isStaticConfigKey(k)) {
if (isStaticConfigKey(k)) {
throw new KyuubiException(s"Cannot modify the value of a static config: $k")
}
conf.setConfString(k, v)
Expand All @@ -419,6 +420,21 @@ class SparkArrowbasedOperationSuite extends WithSparkSQLEngine with SparkDataTyp
}
}
}

/**
* This method provides a reflection-based implementation of [[SQLConf.isStaticConfigKey]] to
* adapt Spark-3.1.x
*
* TODO: Once we drop support for Spark 3.1.x, we can directly call
* [[SQLConf.isStaticConfigKey()]].
*/
private def isStaticConfigKey(key: String): Boolean = {
val staticConfKeys = DynFields.builder()
.hiddenImpl(SQLConf.getClass, "staticConfKeys")
.build[java.util.Set[String]](SQLConf)
.get()
staticConfKeys.contains(key)
}
}

case class TestData(key: Int, value: String)
Expand Down

0 comments on commit 8280783

Please sign in to comment.