pyspark为什么df写入循环覆盖前面的表

时间:2018-06-14 23:11:19

标签: pyspark pyspark-sql

嗨,我有以下代码:

for i in range(10):
    df_combined = combine_data(df_1, df_2, 1)
    df_combined.cache()
    df_combined.count()

    temp = df_combined
    temp = temp.withColumn("months_back", lit(int('{}'.format(i))))
    temp.write.mode("overwrite").saveAsTable("adhoc.test_month_{}".format(i), 
                               path="s3://my_path/my_bucket")

但是当我做的时候

select * from test_month_0

我得到与

相同的表格
select * from test_month_1

即使对于months_back列,我在两个表中得到值为1。

我做错了什么?

0 个答案:

没有答案