This project has retired. For details please refer to its Attic page.
Metron – Stellar Interpreter for Apache Zeppelin

Stellar Interpreter for Apache Zeppelin

Apache Zeppelin is a web-based notebook that enables data-driven, interactive data analytics and collaborative documents with SQL, Scala and more. This project provides a means to run the Stellar REPL directly within a Zeppelin Notebook.

Prerequisites

  • Apache Zeppelin 0.7.3

    This is tested with version 0.7.3. Other versions may work, but are not supported.

Installation

Currently, you need to manually install the Stellar Interpreter in Zeppelin. In the future this step could be automated by the Metron Mpack.

To install the Stellar Interpreter in your Apache Zeppelin installation, follow these instructions. This is paraphrased from the Zeppelin docs.

  1. Build and install Metron. Metron and its dependencies will be retrieved from your local Maven repository.

    cd $METRON_HOME
    mvn clean install -DskipTests
    
  2. If you do not already have Zeppelin installed, download and unpack Apache Zeppelin. Then change directories to the root of your Zeppelin download.

    cd $ZEPPELIN_HOME
    
  3. Use Zeppelin’s installation utility to install the Stellar Interpreter.

    If Zeppelin was already installed, make sure that it is stopped before running this command. Update the version, ‘0.7.1’ in the example below, to whatever is appropriate for your environment.

    bin/install-interpreter.sh --name stellar --artifact org.apache.metron:stellar-zeppelin:0.7.1
    

    Note: The above command will download maven artifact groupId1:artifact1:version1 (org.apache.metron:stellar-zeppelin:0.7.1) and all of its transitive dependencies into the $ZEPPELIN_HOME/interpreter/stellar directory. stellar-common, which contains many of the Stellar Core Functions, will be included transitively because stellar-zeppelin declares it as a direct dependency in its Maven pom.xml.

  4. Start Zeppelin.

    bin/zeppelin-daemon.sh start
    
  5. Navigate to Zeppelin running at http://localhost:8080/. The Stellar Interpreter should be ready for use with a basic set of functions.

Usage

  1. Create a new notebook.

    1. Click on “Notebook” > “Create new note”.

    2. Set the default Interpreter to stellar.

      When creating the notebook, if you define stellar as the default interpreter, then there is no need to enter %stellar at the top of each code block.

      If stellar is not the default interpreter, then you must enter %stellar at the top of a code block containing Stellar code.

  2. In the first block, add the following Stellar, then click Run.

    2 in [2,3,4]
    
  3. In the next block, check which functions are available to you.

    When executing Stellar’s magic functions, you must explicitly define which interpreter should be used in the code block. If you define ‘stellar’ as the default interpreter when creating a notebook, then this is only required when using Stellar’s magic functions.

    %stellar
    
    %functions
    

    You will only ‘see’ the functions defined within stellar-common since that is the only library that we added to the interpreter.

  4. Add additional Stellar functions to your session.

    1. Go back to the Stellar interpreter configuration and add another dependency as follows.

      org.apache.metron:metron-statistics:0.7.1
      
    2. Go back to your notebook and run %functions again. You will now see the additional functions defined within the metron-statistics project.

  5. Auto-completion is also available for Stellar expressions.

    In another block, type ‘TO_’ then press the CTRL + PERIOD keys. This will trigger the auto-complete mechanism in Stellar and display a list of matching functions or variables.