【问题标题】:Write Pyspark Dataframe to Hive table - name 'database' is not defined Error将 Pyspark 数据框写入 Hive 表 - 未定义名称“数据库”错误
【发布时间】:2020-11-07 17:34:25
【问题描述】:

我正在尝试使用 Jupyternotebook 上的以下代码将 pyspark 数据帧写入配置单元表:

df.repartition("dt").write.partitionBy("dt").format("orc").saveAsTable(fraud_nr.test)

fraud_nr 是我试图将表写入的数据库。但是我得到了这个错误。

> NameError: name 'fraud_nr' is not defined

我想知道我还需要做什么才能写入这个数据库。

【问题讨论】:

    标签: dataframe apache-spark pyspark hive jupyter-notebook


    【解决方案1】:

    db_name.table_name 括在 quotes(")

    df.repartition("dt").write.partitionBy("dt").format("orc").saveAsTable("fraud_nr.test")
    

    【讨论】:

      猜你喜欢
      • 2020-11-26
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-15
      相关资源
      最近更新 更多