I'm perplexed between the behaviour of numPartitions
parameter in the following methods:
DataFrameReader.jdbc
Dataset.repartition
The official docs of DataFrameReader.jdbc
say following regarding numPartitions
parameter
numPartitions: the number of partitions. This, along with lowerBound (inclusive), upperBound (exclusive), form partition strides for generated WHERE clause expressions used to split the column columnName evenly.
And official docs of Dataset.repartition
say
Returns a new Dataset that has exactly
numPartitions
partitions.
My current understanding:
- The
numPartition
parameter inDataFrameReader.jdbc
method controls the degree of parallelism in reading the data from database - The
numPartition
parameter inDataset.repartition
controls the number of output files that will be generated when thisDataFrame
would be written to disk
My questions:
- If I read
DataFrame
viaDataFrameReader.jdbc
and then write it to disk (without invokingrepartition
method), then would there still be as many files in output as there would've been had I written out aDataFrame
to disk after having invokedrepartition
on it? - If the answer to the above question is:
- Yes: Then is it redundant to invoke
repartition
method on aDataFrame
that was read usingDataFrameReader.jdbc
method (withnumPartitions
parameter)? - No: Then please correct the lapses in my understanding. Also in that case shouldn't the
numPartitions
parameter ofDataFrameReader.jdbc
method be called something like 'parallelism'?
- Yes: Then is it redundant to invoke