Re: spark partitionBy with partitioned column in json output
Had the same issue my self. I was surprised at first as well, but I found it useful - the amount of data saved for each partition has decreased. When I load the data from each partition, I add the partitioned columns with lit function before I merge the frames from the different partitions. On Tue, Jun 5, 2018 at 5:44 AM, Jay wrote: > The partitionBy clause is used to create hive folders so that you can > point a hive partitioned table on the data . > > What are you using the partitionBy for ? What is the use case ? > > > On Mon 4 Jun, 2018, 4:59 PM purna pradeep, > wrote: > >> im reading below json in spark >> >> {"bucket": "B01", "actionType": "A1", "preaction": "NULL", >> "postaction": "NULL"} >> {"bucket": "B02", "actionType": "A2", "preaction": "NULL", >> "postaction": "NULL"} >> {"bucket": "B03", "actionType": "A3", "preaction": "NULL", >> "postaction": "NULL"} >> >> val df=spark.read.json("actions.json").toDF() >> >> Now im writing the same to a json output as below >> >> df.write. format("json"). mode("append"). >> partitionBy("bucket","actionType"). >> save("output.json") >> >> >> and the output.json is as below >> >> {"preaction":"NULL","postaction":"NULL"} >> >> bucket,actionType columns are missing in the json output, i need >> partitionby columns as well in the output >> >>
Re: spark partitionBy with partitioned column in json output
The partitionBy clause is used to create hive folders so that you can point a hive partitioned table on the data . What are you using the partitionBy for ? What is the use case ? On Mon 4 Jun, 2018, 4:59 PM purna pradeep, wrote: > im reading below json in spark > > {"bucket": "B01", "actionType": "A1", "preaction": "NULL", > "postaction": "NULL"} > {"bucket": "B02", "actionType": "A2", "preaction": "NULL", > "postaction": "NULL"} > {"bucket": "B03", "actionType": "A3", "preaction": "NULL", > "postaction": "NULL"} > > val df=spark.read.json("actions.json").toDF() > > Now im writing the same to a json output as below > > df.write. format("json"). mode("append"). > partitionBy("bucket","actionType"). save("output.json") > > > and the output.json is as below > > {"preaction":"NULL","postaction":"NULL"} > > bucket,actionType columns are missing in the json output, i need > partitionby columns as well in the output > >
Re: spark partitionBy with partitioned column in json output
Purna, This behavior is by design. If you provide partitionBy, Spark removes the columns from the data From: purna pradeep Date: Monday, June 4, 2018 at 8:00 PM To: "user@spark.apache.org" Subject: spark partitionBy with partitioned column in json output im reading below json in spark {"bucket": "B01", "actionType": "A1", "preaction": "NULL", "postaction": "NULL"} {"bucket": "B02", "actionType": "A2", "preaction": "NULL", "postaction": "NULL"} {"bucket": "B03", "actionType": "A3", "preaction": "NULL", "postaction": "NULL"} val df=spark.read.json("actions.json").toDF() Now im writing the same to a json output as below df.write. format("json"). mode("append"). partitionBy("bucket","actionType"). save("output.json") and the output.json is as below {"preaction":"NULL","postaction":"NULL"} bucket,actionType columns are missing in the json output, i need partitionby columns as well in the output The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates and may only be used solely in performance of work or services for Capital One. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
spark partitionBy with partitioned column in json output
im reading below json in spark {"bucket": "B01", "actionType": "A1", "preaction": "NULL", "postaction": "NULL"} {"bucket": "B02", "actionType": "A2", "preaction": "NULL", "postaction": "NULL"} {"bucket": "B03", "actionType": "A3", "preaction": "NULL", "postaction": "NULL"} val df=spark.read.json("actions.json").toDF() Now im writing the same to a json output as below df.write. format("json"). mode("append"). partitionBy("bucket","actionType"). save("output.json") and the output.json is as below {"preaction":"NULL","postaction":"NULL"} bucket,actionType columns are missing in the json output, i need partitionby columns as well in the output