【问题标题】:Pyspark cannot create a parquet table in hivePyspark 无法在 hive 中创建镶木地板表
【发布时间】:2017-03-20 18:55:44
【问题描述】:

许多搜索指向 pyspark 代码以在 hive 元存储中创建表,例如:

hivecx.sql("...create table syntax that matches the dataframe...") df.write.mode("overwrite").partitionBy('partition_colname').insertInto("national_dev.xh_claimline")

我尝试了许多写/保存/插入和模式的变体,但总是得到:

Caused by: java.io.FileNotFoundException: File does not exist: /user/hive/warehouse/national_dev.db/xh_claimline/000000_0

表目录存在于 hadoop 中,但 000000_0 子目录不存在。我以为这是因为表是空的,我还没有写信。

hadoop fs -ls /user/hive/warehouse/national_dev.db/xh_claimline Found 2 items drwxrwxrwt - mryan hive 0 2017-03-20 12:26 /user/hive/warehouse/national_dev.db/xh_claimline/.hive-staging_hive_2017-03-20_12-26-35_382_2703713921168172595-1 drwxrwxrwt - mryan hive 0 2017-03-20 12:29 /user/hive/warehouse/national_dev.db/xh_claimline/.hive-staging_hive_2017-03-20_12-29-40_775_73045420253990110-1

在 Cloudera 上,Spark 版本: 17/03/20 11:45:21 信息 spark.SparkContext:运行 Spark 版本 1.6.0

【问题讨论】:

    标签: hive pyspark parquet


    【解决方案1】:

    查看insert into语句,这里使用数据写入模式overwrite,则无需写入insert in to。直接使用saveAsTableparquet 格式。这是修改后的声明:-

    df = hivecx.sql("...create table syntax that matches the dataframe...")
    df.write.mode("overwrite").format("parquet").partitionBy('partition_colname').saveAsTable("national_dev.xh_claimline")
    

    【讨论】:

    • 谢谢@rakesh-kumar - 我以前试过,但我刚才又试了一次以确保。我得到完全相同的结果。 Caused by: java.io.FileNotFoundException: File does not exist: /user/hive/warehouse/national_dev.db/xh_claimline/000000_0
    • @MattRyan 那么我认为您没有名为 national_dev 的数据库,因此请通过 hive shell 确保数据库存在
    猜你喜欢
    • 2021-10-14
    • 2019-03-17
    • 2019-06-09
    • 2016-08-22
    • 2020-11-07
    • 2019-10-13
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多