提问者:小点点

从Spark 2.4迁移到Spark 3。Spark 2.4的SharedSQLContext在Spark 3中的等效项是什么?


我对java/scala相当陌生。我在Spark 3 repo中找不到< code>SharedSQLContext。我们一般如何在更新版本中找到类的等价物?我找不到这方面的任何文件。谢谢大家!

现有类示例:

class KafkaDataConsumerSuite extends SharedSQLContext with PrivateMethodTester {

  protected var testUtils: KafkaTestUtils = _

  override def beforeAll(): Unit = {
    super.beforeAll()
    testUtils = new KafkaTestUtils(Map[String, Object]())
    testUtils.setup()
  }

  override def afterAll(): Unit = {
    if (testUtils != null) {
      testUtils.teardown()
      testUtils = null
    }
    super.afterAll()
  }

  test("SPARK-19886: Report error cause correctly in reportDataLoss") {
    val cause = new Exception("D'oh!")
    val reportDataLoss = PrivateMethod[Unit]('reportDataLoss0)
    val e = intercept[IllegalStateException] {
      BlackbirdInternalKafkaConsumer.invokePrivate(reportDataLoss(true, "message", cause))
    }
    assert(e.getCause === cause)
  }
}

共1个答案

匿名用户

在Spark 3中,已删除SharedSQLContext类和相关API。Spark 2.4 中的 SharedSQLContext 等效项是 SparkSession 对象。

SparkSession为在Spark中处理结构化数据提供了一个入口点,它封装了以前在SQLContextHiveContext中找到的所有功能。