小编Sam*_*ort的帖子

PySpark/HIVE:附加到现有表

非常基本的问题 pyspark/hive 问题:

如何附加到现有表?我的尝试如下

from pyspark import SparkContext, SparkConf
from pyspark.sql import HiveContext
conf_init = SparkConf().setAppName('pyspark2')
sc = SparkContext(conf = conf_init)
hive_cxt = HiveContext(sc)

import pandas as pd
df = pd.DataFrame({'a':[0,0], 'b':[0,0]})
sdf = hive_cxt.createDataFrame(df)
sdf.write.mode('overwrite').saveAsTable('database.table') #this line works

df = pd.DataFrame({'a':[1,1,1], 'b':[2,2,2]})
sdf = hive_cxt.createDataFrame(df)
sdf.write.mode('append').saveAsTable('database.table') #this line does not work
#sdf.write.insertInto('database.table',overwrite = False) #this line does not work
Run Code Online (Sandbox Code Playgroud)

谢谢!山姆

python hive apache-spark pyspark

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

apache-spark ×1

hive ×1

pyspark ×1

python ×1