【问题标题】:Spark integration with Vertica FailingSpark 与 Vertica 的集成失败
【发布时间】:2022-05-20 02:10:35
【问题描述】:

我们正在使用 Vertica 社区版“vertica_community_edition-11.0.1-0”,并且正在使用带有本地 [*] 主控的 Spark 3.2。当我们尝试使用以下方法将数据保存在 vertica 数据库中时:

member.write()
                .format("com.vertica.spark.datasource.VerticaSource")
                .mode(SaveMode.Overwrite)
                .option("host", "192.168.1.25")
                .option("port", "5433")
                .option("user", "Fred")
                .option("db", "store")
                .option("password", "password")
                //.option("dbschema", "store")
                .option("table", "Test")
                //      .option("staging_fs_url", "hdfs://172.16.20.17:9820")
                .save();

我们得到以下异常:

com.vertica.spark.util.error.ConnectorException: Fatal error: spark context did not exist
        at com.vertica.spark.datasource.VerticaSource.extractCatalog(VerticaDatasourceV2.scala:76)
        at org.apache.spark.sql.connector.catalog.CatalogV2Util$.getTableProviderCatalog(CatalogV2Util.scala:363)

请告知如何解决异常。

【问题讨论】:

    标签: apache-spark vertica


    【解决方案1】:

    vertica 正式不支持带有 vertica 11.0 的 spark 版本 3.2。请找到以下文档链接。

    https://www.vertica.com/docs/11.0.x/HTML/Content/Authoring/SupportedPlatforms/SparkIntegration.htm

    请尝试将 spark connector v2 与支持的 spark 版本一起使用,并尝试从 github 运行示例

    https://github.com/vertica/spark-connector/tree/main/examples

    【讨论】:

      【解决方案2】:

      我们有一个类似的案例。根本原因是SparkSession.getActiveSession() 返回了None,因为该 spark 会话已在 JVM 的另一个线程上注册。我们仍然可以使用SparkSession.getDefaultSession() 访问我们拥有的单个会话,并使用SparkSession.SetActiveSession(...) 手动注册它。

      我们的案例发生在我们使用 pyspark 的 jupyter 内核中。
      解决方法代码是:

      sp = sc._jvm.SparkSession.getDefaultSession().get()
      sc._jvm.SparkSession.setActiveSession(sp)
      

      我不能尝试 scala 或 java,我想它应该是这样的:

      SparkSession.setActiveSession(SparkSession.getDefaultSession())
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-05
        • 2017-01-01
        • 1970-01-01
        相关资源
        最近更新 更多