Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: repartition bug in LightGBMRanker #1368

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,24 @@ class LightGBMRanker(override val uid: String)
if (getRepartitionByGroupingColumn) {
val repartitionedDataset = getOptGroupCol match {
case None => dataset
case Some(groupingCol) => {
val df = dataset.repartition(new Column(groupingCol)).cache()
//force materialization
df.count
df
}
case Some(groupingCol) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall this logic was modified in this PR from another user for the ranker:
#778
who had issues with this logic, so I would just be careful here

val numPartitions = dataset.rdd.getNumPartitions

// in barrier mode, will use repartition in super.prepareDataframe,
// this will let repartition on groupingCol fail
// so repartition here, then super.prepareDataframe won't repartion
if (getUseBarrierExecutionMode) {
if (numPartitions > numTasks) {
dataset.repartition(numTasks, new Column(groupingCol))
} else {
dataset.repartition(numPartitions, new Column(groupingCol))
}
} else {
// if not in barrier mode, coalesce won't break repartition by groupingCol
dataset.repartition(new Column(groupingCol))
}
}

super.prepareDataframe(repartitionedDataset, numTasks)
} else {
super.prepareDataframe(dataset, numTasks)
Expand Down