在pyspark中激活Hive上的acid缺少什么?

xmakbtuz  于 2021-06-24  发布在  Hive
关注(0)|答案(1)|浏览(367)

我想更新配置单元表中的一些行。因为pyspark根本不识别update,所以我选择了delete和insert,但是在delete操作上得到了“不允许操作”。
为了解决这个问题,我将表指定为orc,并尝试了此站点上提到的其他要求:https://cwiki.apache.org/confluence/display/hive/hive+transactions#hivetransactions-局限性
我还设置了tableproperty“transactional”=“true”。下面您将看到一些代码我如何尝试设置属性

sqlCtx.sql("""SET spark.hadoop.hive.support.concurrency=true""")
sqlCtx.sql("""SET spark.hadoop.hive.enforce.bucketing=true""")
sqlCtx.sql("""SET spark.hadoop.hive.exec.dynamic.partition.mode=nonstrict""")
sqlCtx.sql("""SET spark.hadoop.hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager""")
sqlCtx.sql("""SET spark.hadoop.hive.lock.manager=org.apache.hadoop.hive.ql.lockmgr.zookeeper.ZooKeeperHiveLockManager""")
sqlCtx.sql("""SET spark.hadoop.hive.compactor.initiator.on=true""")
sqlCtx.sql("""SET spark.hadoop.hive.compactor.worker.threads=1""")

# Some other stuff happens creating the values etc

# Then I create the table from another table as orc

sqlCtx.sql("CREATE TABLE " + name + " AS SELECT * FROM new_base AS orc")
sqlCtx.sql("ALTER TABLE " + name + """ SET TBLPROPERTIES("transactional"="true")""")

# This will now result in Operation not allowed

sqlCtx.sql("DELETE FROM " + name) # I didn't keep the Where clause as it makes no difference so the error is not in the missing Where clause

我希望delete子句可以执行某些操作,至少由于缺少where子句而引发了一个错误,但我只得到pyspark.sql.utils.parseexception:'\n不允许的操作:delete from。。。
如果创建一个表的完整代码示例更有帮助,那么在注解中写下它,我会添加它,为了更好的可读性,我把它放在一边。我还应该注意到,这是完全在本地运行的。

e7arh2l6

e7arh2l61#

我认为应该在hive-site.xml文件中添加相应的配置单元配置
另外,只有在运行单独的配置单元服务器并且必须对配置单元服务器启动查询时,配置单元事务功能才起作用。spark中的配置单元只是嵌入式元存储(存储spark完成的元数据处理)。由于嵌入式元存储没有配置单元服务器,它将无法工作。
要使用事务,您需要安装配置单元并在hive-site.xml中设置这些属性,然后使用spark连接到配置单元服务器urlhttps://github.com/gowthamsb12/spark/blob/master/spark_acidhow 要访问sparksql中的配置单元acid表?
例如,对应的配置单元属性 spark.hadoop.hive.support.concurrency=true

<property>
  <name>hive.support.concurrency</name>
  <value>true</value>
</property>

相关问题