-
Notifications
You must be signed in to change notification settings - Fork 861
fix: Eliminate RDD usage across SynapseML for Spark 4.0 compatibility #2517
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -218,14 +218,8 @@ object SyntheticEstimator { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private[causal] def assignRowIndex(df: DataFrame, colName: String): DataFrame = { | ||||||||||||
| df.sparkSession.createDataFrame( | ||||||||||||
| df.rdd.zipWithIndex.map(element => | ||||||||||||
| Row.fromSeq(Seq(element._2) ++ element._1.toSeq) | ||||||||||||
| ), | ||||||||||||
| StructType( | ||||||||||||
| Array(StructField(colName, LongType, nullable = false)) ++ df.schema.fields | ||||||||||||
| ) | ||||||||||||
| ) | ||||||||||||
| df.withColumn(colName, monotonically_increasing_id()) | ||||||||||||
| .select(col(colName) +: df.columns.map(col): _*) | ||||||||||||
|
Comment on lines
+221
to
+222
|
||||||||||||
| df.withColumn(colName, monotonically_increasing_id()) | |
| .select(col(colName) +: df.columns.map(col): _*) | |
| val windowSpec = Window.orderBy(df.columns.map(col): _*) | |
| val indexedDf = df.withColumn(colName, row_number().over(windowSpec) - 1) | |
| indexedDf.select(col(colName) +: df.columns.map(col): _*) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,8 @@ import com.microsoft.azure.synapse.ml.logging.{FeatureNames, SynapseMLLogging} | |
| import org.apache.spark.ml.Transformer | ||
| import org.apache.spark.ml.param._ | ||
| import org.apache.spark.ml.util.{DefaultParamsReadable, DefaultParamsWritable, Identifiable} | ||
| import org.apache.spark.rdd.RDD | ||
| import org.apache.spark.sql.types._ | ||
| import org.apache.spark.sql.{DataFrame, Dataset, Row} | ||
| import org.apache.spark.sql.{DataFrame, Dataset} | ||
|
|
||
| object Repartition extends DefaultParamsReadable[Repartition] | ||
|
|
||
|
|
@@ -50,12 +49,8 @@ class Repartition(val uid: String) extends Transformer with Wrappable with Defau | |
| logTransform[DataFrame]({ | ||
| if (getDisable) | ||
| dataset.toDF | ||
| else if (getN < dataset.rdd.getNumPartitions) | ||
| dataset.coalesce(getN).toDF() | ||
| else | ||
| dataset.sqlContext.createDataFrame( | ||
| dataset.rdd.repartition(getN).asInstanceOf[RDD[Row]], | ||
| dataset.schema) | ||
| dataset.repartition(getN).toDF() | ||
| }, dataset.columns.length) | ||
|
Comment on lines
49
to
54
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dfWithFoldis not cached, so each fold’strainingandvalidationDataFrames will independently re-evaluate therand(getSeed)expression and re-scan the input. PersistingdfWithFoldonce (and unpersisting after buildingsplits) would both reduce work and ensure the fold assignment is identical across all derived DataFrames even if the optimizer rewrites the plan.