Hey all.

I just did a pull build to utilize this bug fix, but I'm still getting the
error when creating companions

My code:

%spark


case class Person (var name: String, var age: Int)
// the companion object
object Person{
    def apply() = new Person("<no name>", 0)
    def apply(name: String) = new Person(name, 0)
}

My result:
defined class Person
defined module Person
warning: previously defined class Person is not a companion to object
Person.
Companions must be defined together; you may wish to use :paste mode for
this.
FINISHED

Thoughts? E.g. what am I doing wrong here?


Also I *really* want this for Flink, so I coppied and pasted the update,
which compiles- but doesn't work as expected, however it doesn't work as
expected on Spark either- which makes me think this is a case of user
error. I can create a PR to update the Flink 'terp once I get expected
results.

tg



Trevor Grant
Data Scientist
https://github.com/rawkintrevo
http://stackexchange.com/users/3002022/rawkintrevo
http://trevorgrant.org

*"Fortunate is he, who is able to know the causes of things."  -Virgil*


On Fri, Feb 5, 2016 at 2:42 AM, Ruggero Rossi (JIRA) <j...@apache.org>
wrote:

> Ruggero Rossi created ZEPPELIN-658:
> --------------------------------------
>
>              Summary: Scala: not accepting companion objects if defined in
> different lines
>                  Key: ZEPPELIN-658
>                  URL: https://issues.apache.org/jira/browse/ZEPPELIN-658
>              Project: Zeppelin
>           Issue Type: Improvement
>     Affects Versions: 0.5.6
>          Environment: Linux Centos 7, Spark 1.6, Scala 2.10.6
>             Reporter: Ruggero Rossi
>
>
>
> In Scala 2.10.x, a companion object must be in the same source file as the
> related class, otherwise Scala will not accept it as a proper companion.
> Now, it appears to me that Zeppelin sends every single line in a paragraph
> as a separate line to the Scala REPL.
> Doing so, it makes impossible for the companion object to be accepted.
> I will make an example:. If I write in a Zeppelin paragraph:
>
> // the case class
> case class Person (var name: String, var age: Int)
>
> // the companion object
> object Person {
>   def apply() = new Person("<no name>", 0)
>   def apply(name: String) = new Person(name, 0)
> }
>
> I receive the following error:
> warning: previously defined class Person is not a companion to object
> Person. Companions must be defined together; you may wish to use :paste
> mode for this.
>
> Now, if instead I paste everything on the same line, it works well:
>
> case class Person (var name: String, var age: Int); object Person {  def
> apply() = new Person("<no name>", 0);   def apply(name: String) = new
> Person(name, 0); }
>
> So it looks like this issue could be solved either by writing a text
> processor that parses each line and paste them into a single line using
> semicolons in the right places, or Zeppelin could just send the command
> “:paste” to the Scala REPL (or have a setting that permits so).
>
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)
>

Reply via email to