You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ru...@apache.org on 2026/09/09 01:56:12 UTC

(spark) branch master updated: [SPARK-59337][ML] Simplify GeneralizedLinearRegressionModel transform implementation

This is an automated email from the ASF dual-hosted git repository.

zhengruifeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 9de2f8df6f7e [SPARK-59337][ML] Simplify GeneralizedLinearRegressionModel transform implementation
9de2f8df6f7e is described below

commit 9de2f8df6f7e69acb140a2763a24c5576c112948
Author: Ruifeng Zheng <ru...@apache.org>
AuthorDate: Wed Sep 9 09:56:00 2026 +0800

    [SPARK-59337][ML] Simplify GeneralizedLinearRegressionModel transform implementation
    
    ### What changes were proposed in this pull request?
    
    This PR removes the redundant `GeneralizedLinearRegressionModel.transformImpl` override and keeps
    its implementation directly in `transform`.
    
    ### Why are the changes needed?
    
    `GeneralizedLinearRegressionModel` must override `transform` because it can produce
    `linkPredictionCol` when `predictionCol` is empty, while the base `Predictor` implementation only
    invokes `transformImpl` when `predictionCol` is set. Once GLR owns `transform`, the separate
    `transformImpl` override is only called by that method. Previously, `transform` called
    `transformSchema` and then delegated to `transformImpl`, which immediately called
    `transformSchema` again. As a result, each transform checked the schema twice.
    
    Inlining the implementation removes this redundant indirection and schema validation without
    changing the generated columns.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    The following checks passed:
    
    ```
    build/sbt mllib/compile
    build/sbt 'mllib/testOnly org.apache.spark.ml.regression.GeneralizedLinearRegressionSuite'
    ```
    
    `GeneralizedLinearRegressionSuite` ran 29 tests successfully, with one ignored test.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: OpenAI Codex (GPT-5)
    
    Closes #58624 from zhengruifeng/ml-spark-59337-glr-transform-dev-7.
    
    Authored-by: Ruifeng Zheng <ru...@apache.org>
    Signed-off-by: Ruifeng Zheng <ru...@foxmail.com>
---
 .../org/apache/spark/ml/regression/GeneralizedLinearRegression.scala | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala b/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
index ac9363511320..7b79f73070a2 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala
@@ -1051,11 +1051,6 @@ class GeneralizedLinearRegressionModel private[ml] (
   }
 
   override def transform(dataset: Dataset[_]): DataFrame = {
-    transformSchema(dataset.schema)
-    transformImpl(dataset)
-  }
-
-  override protected def transformImpl(dataset: Dataset[_]): DataFrame = {
     val outputSchema = transformSchema(dataset.schema, logging = true)
 
     val offset = if (!hasOffsetCol) lit(0.0) else col($(offsetCol)).cast(DoubleType)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org