在Apache Spark SQL中我们可以回滚事务吗 [英] In Apache spark SQL can we roll back the transactions

查看:557
本文介绍了在Apache Spark SQL中我们可以回滚事务吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使数据的spark sql持久化,在那种情况下我可以使用回滚数据来保持持久化.例

假设我们有3个表t1,t2和t3. t1和t2表数据已成功持久保存,但在数据完整性级别上t3如何失败.所以我可以回滚我一直坚持的t1和t2数据.

我的意思是我可以回滚交易吗?

解决方案

浏览Spark代码(从v1.6.2到v2.1.0),似乎甚至没有指定 when 提交,也不回滚.

假设您保存/写入一个数据框,最终savePartition被调用并以:

结尾

  if (supportsTransactions) {
    conn.commit()
  }

来源: 解决方案

Looking through the Spark code (v1.6.2 up to v2.1.0), there doesn't even seem to be an option to specify when to commit, nor rollback.

Assuming you save/write a Dataframe, eventually savePartition gets called and ends with:

  if (supportsTransactions) {
    conn.commit()
  }

Source: https://github.com/apache/spark/blob/v2.1.0/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala#L602-L604

You can always look into adding this feature yourself in the source code :) (and pull-request upstream!)

这篇关于在Apache Spark SQL中我们可以回滚事务吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆