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

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

问题描述

我想让数据持久化的spark sql,在这种情况下,我可以使用我们已经持久化的回滚数据.例如

I want to make spark sql for data persistent, in that case can I use roll back data what we have persisted. Ex.

假设我们有 3 个表 t1、t2 和 t3.t1 和 t2 表数据成功持久化,但在某些方面 t3 数据完整性级别失败.所以我可以回滚我坚持的 t1 和 t2 数据.

let say we have 3 tables t1,t2 and t3. t1 and t2 table data is persisted successfully but some how t3 failed in data integrity level. so can I roll back t1 and t2 data wt I have persisted.

我的意思是我可以回滚一个事务.

I mean can I roll back a transaction.

推荐答案

查看 Spark 代码(v1.6.2 到 v2.1.0),甚至似乎没有一个选项可以指定 when 提交,也不回滚.

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.

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

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

  if (supportsTransactions) {
    conn.commit()
  }

来源:https://github.com/apache/spark/blob/v2.1.0/sql/core/src/main/scala/org/apache/spark/sql/execution/数据源/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天全站免登陆