Hello Martin

 I faced the same issue as you when I tried to write the Cassandra
interpreter using full Scala.

 You need to know that the magic of interpreter discovery is given by

static {
   Interpreter.register(...)
}

 There is no option to "emulate" a static block in Scala. Putting an init
code block into an object like you did won't work. Try to put a break point
in debug mode inside the Interpreter.register(...) method and you'll see it
is never called for your Scala interpreter. Indeed, the init code in a
Scala object is called only the first time the object is accessed. But
since it is not registered by the static block, it will never be called ...

 The work-around is:

1. Create the interpreter class in Java and register it using Java static
block
2. Delegate all the logic of your interpreter to a Scala object/class

For more details, look here:
https://github.com/apache/incubator-zeppelin/blob/master/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java

On Thu, Nov 5, 2015 at 10:45 PM, Martin Studer <martin.remo.stu...@gmail.com
> wrote:

> Hi,
>
> I'm trying to implement a Zeppelin interpreter in Scala. I have everything
> ready in the following form:
>
> package my.interpreter
>
> object MyInterpreter {
>   Interpreter.register("MyInterpreter", classOf[MyInterpreter].getName)
> }
>
> class MyInterpreter(property: Properties) extends Interpreter(property) {
>   ...
> }
>
> When I register "my.interpreter.MyInterpreter$" (note the '$' due to
> Scala's name mangling) in the zeppelin-site.xml file, I see the
> corresponding interpreter name "MyInterpreter" in the choices in the web
> interface when creating a new interpreter. However, when saving the
> configuration the interpreter is not actually added. In the log files I
> don't find any hint that would suggest that something went wrong. Is there
> something special that needs to be considered when implementing
> interpreters in Scala?
>
> I've been using the current development version of zeppelin from github.
>
> Any hints are very much appreciated.
>
> Best regards,
> Martin
>
>

Reply via email to