我正试图使用火花连接器(pyspark)将火花数据存储到点燃缓存中,如下所示:
df.write.format("jdbc") \
.option("url", "jdbc:ignite:thin://<ignite ip>") \
.option("driver", "org.apache.ignite.IgniteJdbcThinDriver") \
.option("primaryKeyFields", 'id') \
.option("dbtable", "ignite") \
.mode("overwrite") \
.save()
# .option("createTableOptions", "primary key (id)") \
# .option("customSchema", 'id BIGINT PRIMARY KEY, txt TEXT') \我有个错误:
java.sql.SQLException: No PRIMARY KEY defined for CREATE TABLE程序库org.apache.ignite:点燃-火花-2.4:2.9.0已安装。我不能使用点燃格式,因为azure使用了与org.apache.ignite中的spring框架版本冲突的spring框架版本-2.4:2.9.0。所以我尝试使用jdbc瘦客户机。但我只能将数据读取/追加到现有的缓存中。
我不能使用覆盖模式,因为我不能选择主键。有一个选项primaryKeyFields用于点燃格式,但它不适用于jdbc。jdbc customSchema选项被忽略。createTableOptions在架构括号和出现sql语法错误后添加主键语句。
是否有方法确定jdbc火花连接器的主键?
发布于 2020-10-30 13:57:45
下面是一个具有正确语法的示例,应该可以很好地工作:
DataFrameWriter < Row > df = resultDF
.write()
.format(IgniteDataFrameSettings.FORMAT_IGNITE())
.option(IgniteDataFrameSettings.OPTION_CONFIG_FILE(), configPath)
.option(IgniteDataFrameSettings.OPTION_TABLE(), "Person")
.option(IgniteDataFrameSettings.OPTION_CREATE_TABLE_PRIMARY_KEY_FIELDS(), "id, city_id")
.option(IgniteDataFrameSettings.OPTION_CREATE_TABLE_PARAMETERS(), "template=partitioned,backups=1")
.mode(Append);如果这里出了什么问题,请告诉我。
https://stackoverflow.com/questions/64554684
复制相似问题