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

gurwls223 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 e92bf3746ebf [SPARK-49978][R] Move sparkR deprecation warning to 
package attach time
e92bf3746ebf is described below

commit e92bf3746ebf52028e2bc2168583bf9e1f463434
Author: Tinglong Liao <[email protected]>
AuthorDate: Thu Oct 17 08:13:07 2024 +0900

    [SPARK-49978][R] Move sparkR deprecation warning to package attach time
    
    ### What changes were proposed in this pull request?
    
    Previously, the output deprecation warning happens in the `spark.session` 
function, in this PR, we move it to the `.onAttach` function so it will be 
triggered whenever library is attached
    
    ### Why are the changes needed?
    
    I believe having the warning message on attach time have the following 
benefits:
    
    - **Have a more prompt warning.** If the deprecation is for the whole 
package instead of just the `sparkR.session` function, it is more intuitive for 
the warning to show up on attach time instead of waiting til later time
    - **Do not rely on the assumption of "every sparkR user will run 
sparkR.session method".** This asumption may not hold true all the time. For 
example, some hosted spark platform like Databricks already configure the spark 
session in the background and therefore will not show the error message. So 
making this change should make sure a broader reach for this warning 
notification
    - **Less intrusive warning**. Previous warning show up every time 
`sparkR.session` is called, but the new warning message will only show up once 
even if user run multiple `library`/`require` commands
    
    ### Does this PR introduce _any_ user-facing change?
    
    **Yes**
    1. No more waring message in sparkR.session method
    2. Warning message on library attach (when calling `library`/`require` 
function)
    <img width="859" alt="image" 
src="https://github.com/user-attachments/assets/d88d9108-ec63-4f69-8de6-3f34eeafdd0c";>
    3. Able to surpress warning by setting `SPARKR_SUPPRESS_DEPRECATION_WARNING`
    <img width="733" alt="image" 
src="https://github.com/user-attachments/assets/0266e6dd-3dc7-4c20-b999-b83906f381cd";>
    
    ### How was this patch tested?
    
    Just a simple migration change, will rely on existing pre/post-merge check, 
and this existing test
    Also did manual testing(see previous section for screenshot)
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #48482 from tinglongliao-db/sparkR-deprecation-migration.
    
    Authored-by: Tinglong Liao <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 R/pkg/DESCRIPTION |  1 +
 R/pkg/R/sparkR.R  |  6 ------
 R/pkg/R/zzz.R     | 30 ++++++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/R/pkg/DESCRIPTION b/R/pkg/DESCRIPTION
index f7dd261c10fd..49000c62d106 100644
--- a/R/pkg/DESCRIPTION
+++ b/R/pkg/DESCRIPTION
@@ -57,6 +57,7 @@ Collate:
     'types.R'
     'utils.R'
     'window.R'
+    'zzz.R'
 RoxygenNote: 7.1.2
 VignetteBuilder: knitr
 NeedsCompilation: no
diff --git a/R/pkg/R/sparkR.R b/R/pkg/R/sparkR.R
index 29c05b0db7c2..1b5faad376ea 100644
--- a/R/pkg/R/sparkR.R
+++ b/R/pkg/R/sparkR.R
@@ -403,12 +403,6 @@ sparkR.session <- function(
   sparkPackages = "",
   enableHiveSupport = TRUE,
   ...) {
-
-  if (Sys.getenv("SPARKR_SUPPRESS_DEPRECATION_WARNING") == "") {
-    warning(
-      "SparkR is deprecated from Apache Spark 4.0.0 and will be removed in a 
future version.")
-  }
-
   sparkConfigMap <- convertNamedListToEnv(sparkConfig)
   namedParams <- list(...)
   if (length(namedParams) > 0) {
diff --git a/R/pkg/R/zzz.R b/R/pkg/R/zzz.R
new file mode 100644
index 000000000000..947bd543b75e
--- /dev/null
+++ b/R/pkg/R/zzz.R
@@ -0,0 +1,30 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# zzz.R - package startup message
+
+.onAttach <- function(...) {
+  if (Sys.getenv("SPARKR_SUPPRESS_DEPRECATION_WARNING") == "") {
+    packageStartupMessage(
+      paste0(
+        "Warning: ",
+        "SparkR is deprecated in Apache Spark 4.0.0 and will be removed in a 
future release. ",
+        "To continue using Spark in R, we recommend using sparklyr instead: ",
+        "https://spark.posit.co/get-started/";
+      )
+    )
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to