From fd3b61554495bd54d0f5942e25dd5d24621025ed Mon Sep 17 00:00:00 2001 From: Nate E TeBlunthuis Date: Mon, 6 Jul 2020 22:30:04 -0700 Subject: [PATCH] Cache before sorting so we don't extract twice. --- comments_2_parquet.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/comments_2_parquet.py b/comments_2_parquet.py index 8716abd..069434e 100755 --- a/comments_2_parquet.py +++ b/comments_2_parquet.py @@ -128,6 +128,10 @@ df = df.withColumn("Month",f.month(f.col("CreatedAt"))) df = df.withColumn("Year",f.year(f.col("CreatedAt"))) df = df.withColumn("Day",f.dayofmonth(f.col("CreatedAt"))) df = df.withColumn("subreddit_hash",f.sha2(f.col("subreddit"), 256)[0:3]) + +# cache so we don't have to extract everythin twice +df = df.cache() + df2 = df.sort(["subreddit","author","link_id","parent_id","Year","Month","Day"],ascending=True) df2.write.parquet("/gscratch/comdata/output/reddit_comments_by_subreddit.parquet", partitionBy=["Year",'Month'],mode='overwrite') -- 2.39.2