【发布时间】:2019-07-26 07:01:27
【问题描述】:
我想更新配置单元表中的一些行。由于 pyspark 根本无法识别 UPDATE,因此我选择了 DELETE 和 INSERT,但在 DELETE 操作中出现“不允许操作”。
为了解决这个问题,我将表指定为 orc 并尝试了本网站上提到的其余要求:https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions#HiveTransactions-Limitations
我还设置了 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: '\nOperation not allowed: DELETE FROM ...
如果创建表的完整代码示例更有用,请在 cmets 中写入,我将添加它,我将其保留以提高可读性。我还应该注意,这是完全在本地运行的。
【问题讨论】:
标签: apache-spark hive pyspark acid