在 Apache Spark 中更新到 Phoenix table

Upsert to Phoenix table in Apache Spark

寻找是否有人通过使用 Apache Spark 在 Phoenix 上执行更新插入(附加/更新/部分 inserts/update)的方法。我可以看到,根据 Phoenix documentation 保存 SaveMode.Overwrite 仅受支持 - 它会被满载覆盖。我尝试更改它抛出错误的模式。

目前,我们有 *.hql 作业 运行 执行此操作,现在我们想在 Spark Scala 中重写它们。感谢分享您的宝贵意见。

虽然Phoenix connector确实只支持SaveMode.Overwrite,但实现不符合Spark标准,which states that:

Overwrite mode means that when saving a DataFrame to a data source, if data/table already exists, existing data is expected to be overwritten by the contents of the DataFrame

如果勾选 the source, you'll see that saveToPhoenix just calls saveAsNewAPIHadoopFile with PhoenixOutputFormat, which

internally builds the UPSERT query for you

换句话说,使用 Phoenix Connector 的 SaveMode.Overwrite 实际上是 UPSERT