manuzhang edited a comment on issue #23903: [SPARK-26977][CORE] Fix warn 
against subclassing scala.App
URL: https://github.com/apache/spark/pull/23903#issuecomment-468114310
 
 
   In summary,
   
   1. `spark-submit --class MyApp my-app.jar` works fine 
   
   ```scala
   object MyApp extends scala.App {
   
     val spark = SparkSession.builder
       .getOrCreate()
   
     spark.createDataFrame(Seq("a" -> 1, "b" -> 2, "c" -> 3)).foreachPartition 
{ rowIter =>
       println(rowIter.mkString(","))
     }
   ```
   
   2. `spark-submit --class MyApp my-app.jar foo` will fail since `foo` is 
uninitialized (as in 
[SPARK-4170](https://issues.apache.org/jira/browse/SPARK-4170))
   
   ```scala
   object MyApp extends scala.App {
     val foo = args(0)
     val spark = SparkSession.builder
       .getOrCreate()
   
     spark.createDataFrame(Seq("a" -> 1, "b" -> 2, "c" -> 3)).foreachPartition 
{ rowIter =>
         assert(foo != null)
         println(rowIter.mkString(","))
     }
   ```
   
   3.  `spark-submit --class MyApp$ my-app.jar` fail since `main method must be 
static`
   
   ```scala
   object MyApp extends scala.App {
      // whatever
   }
   ```
   
   4. `spark-submit --class MyApp my-app.jar` fail since `main method must be 
static`
   
   ```scala
   class MyApp extends scala.App {
       // whatever
   }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to