Spark SQL SELECT 有效,但 INSERT 由于 Spark 问题而失败

问题描述 投票:0回答:0

我正在连接到 Spark 中运行的 Iceberg 并查询表。我能够从 Spark-Shell 中进行选择和插入。但是从 Java 代码执行相同的语句时会遇到问题

SparkConf sparkConf = new SparkConf().setAppName("my app");
sparkConf.setMaster("spark://localhost:7077"); // my spark is running in k8s with port-forward
sparkConf.set("spark.shuffle.service.enabled", "false");
sparkConf.set("spark.dynamicAllocation.enabled", "false");
...
// Bunch of Iceberg+Nessie related config properties
...

SparkSession spark = SparkSession
                .builder()
                .config(sparkConf)
                .getOrCreate();
spark.sql("use my;"); // works
spark.sql("SELECT * FROM my.table LIMIT 1;");  // works
spark.sql("INSERT INTO my.table (id, value) VALUES (1, 'test');")  // Does not work. see errors below

这是我所看到的:

Initial job has not accepted any resources; check your cluster UI to ensure that workers are registered and have sufficient resources

但是这个错误具有误导性,因为有足够的资源。 我尝试像这样添加

spark.driver.host

sparkConf.set("spark.driver.host", "localhost");
sparkConf.set("spark.driver.port", "7077");

但这只会导致作业立即退出并请求新的工人。

如何修复此问题以便可以运行查询?为什么只有 INSERT 查询才会出现这种情况?

java apache-spark apache-spark-sql spark-java apache-iceberg
© www.soinside.com 2019 - 2024. All rights reserved.