Uh oh!
There was an error while loading. Please reload this page.
[MINOR][SQL][PYSPARK] Allow user to specify numSlices in SparkSession.createDataFrame - #17926
[MINOR][SQL][PYSPARK] Allow user to specify numSlices in SparkSession.createDataFrame#17926patrick-nicholson wants to merge 3 commits into
Conversation
gatorsmile
commented
May 9, 2017
ok to test |
SparkQA
commented
May 9, 2017
Test build #76698 has finished for PR 17926 at commit
|
SparkQA
commented
May 9, 2017
Test build #76700 has finished for PR 17926 at commit
|
SparkQA
commented
May 9, 2017
Test build #76701 has finished for PR 17926 at commit
|
HyukjinKwon
commented
May 10, 2017
It seems adding a functionality and not a trivial fix. I think we need a JIRA. |
HyukjinKwon
left a comment
There was a problem hiding this comment.
I think this is a rather niche case and we can workaround by parallelizing outside:
>>>df=spark.createDataFrame(spark.sparkContext.parallelize([[1],[2],[3],[4],[5]], numSlices=5))
>>>df.rdd.getNumPartitions()
5Also, this looks only applying when the data is not RDD. I think this is confusing if a user sets this and this option is not working in some cases unless the user reads the documentation.
srowen
commented
May 10, 2017
Does this cause any incompatibility with existing code? |
HyukjinKwon
commented
May 10, 2017
I don't think so (this is Python ... ) for both positional and keyword arguments. (If the new |
It's up to you. All I'm doing is passing a keyword argument from one preexisting public method to another. I don't view that as adding functionality, but I am not the arbiter of such things.
It has been a rather common case for me since I'm often working with Again, I don't see the proposed change as adding any functionality, just exposing machinery already in place for distributing Python data to an
Given that |
HyukjinKwon
commented
May 10, 2017
No, it is not virtually the same before/after (and also we need a regression test). So, it needs a JIRA - see http://spark.apache.org/contributing.html. Adding an parameter to As you said, this can be done in a single line like that, you could just make a wrapper function for it in application side in few lines. defcreateDataFrame(data, numSlices, **kwargs):
returnspark.createDataFrame(
spark.sparkContext.parallelize(data, numSlices=numSlices), **kwargs)I am not sure if it is worth adding this parameter. It looks there is a potential confusion to users and workaround looks so easy. |
gatorsmile
commented
May 10, 2017
How about adding this workaround to the function description of Thanks! |
felixcheung
commented
May 11, 2017
FYI we added |
# What changes were proposed in this pull request? This PR proposes to close stale PRs, mostly the same instances with apache#18017Closesapache#11459Closesapache#13833Closesapache#13720Closesapache#12506Closesapache#12456Closesapache#12252Closesapache#17689Closesapache#17791Closesapache#18163Closesapache#17640Closesapache#17926Closesapache#18163Closesapache#12506Closesapache#18044Closesapache#14036Closesapache#15831Closesapache#14461Closesapache#17638Closesapache#18222 Added: Closesapache#18045Closesapache#18061Closesapache#18010Closesapache#18041Closesapache#18124Closesapache#18130Closesapache#12217 Added: Closesapache#16291Closesapache#17480Closesapache#14995 Added: Closesapache#12835Closesapache#17141 ## How was this patch tested? N/A Author: hyukjinkwon <gurwls223@gmail.com> Closesapache#18223 from HyukjinKwon/close-stale-prs.
What changes were proposed in this pull request?
In my experience, pushing
pandas.DataFrames topyspark.DataFrames will very quickly run up against size issues. These can usually be remedied by changing configuration parameters (e.g.,spark.rpc.message.maxSize), but it is much more convenient to change the level of parallelization used duringRDDcreation. This option is available insparkContext.broadcast. This pull request exposes it tosparkSession.createDataFrame.How was this patch tested?
I have been using a patch implementing this change for a while. I'm only exposing a keyword argument used by an underlying function to the user.