Data science teams use a myriad of different technologies to draw insight from diverse datasets and sources. While Tableau’s current “Analytics Extensions” are robust only for Python, R and Matlab, last year Tableau released an Analytics Extension API to facilitate ad-hoc integration with many outside tools and languages.
In this project, we have built a proof-of-concept Julia web application skeleton using Genie.jl to connect to Tableau with the API, leveraging the Julia programming language within Tableau’s Calculated Field SCRIPT_* functions.
What it does
In short, the tabjulia.jl script provided establishes a localhost server to evaluate Julia computations using the Tableau Analytics Extension API from within Tableau:
1) Creates a Julia Genie.jl back-end server environment 2) Allows connection to the Julia server from Tableau 3) When called upon by Tableau, evaluates the Julia component of the SCRIPT_* code with the provided arguments and returns to Tableau.
Steps for Using Julia Server with Tableau
1) Download or copy the tabjulia.jl script file from Apogee’s GitHub Repository and place in directory of interest. Run the script, installing Genie and HTTP packages if missing. 2) In your Tableau Desktop workbook, open the Managed Analytics Extension Connection. It can be found on the Help menu’s Settings and Performance section. An Analytics Extension Connection window should open up. 3) On the Analytics Extension Connection window, set the service to TabPy/ External API, the Server at localhost and the port specified (8000 by default). Clicking the Test Connection button now should return a “Successful Connection” pop up. 4) Once connected, you can now write your Julia code within a SCRIPT_* table calculation.
How we built it
The two main requirements for establishing a working connection and executing Julia code are setting up two REST API endpoints: /info and /evaluate. The most well-developed Julia web framework available now is Genie, so we used it in this exercise for REST interconnectivity with Tableau.
Within the tabjulia.jl script provided you’ll see the two endpoints are created with route() functions containing the path extensions “/info” and “/endpoint”. Both of these endpoints, along with the possibility to require authentication, are described on the following API Reference page: https://tableau.github.io/analytics-extensions-api/docs/ae_api_ref.html#api-version-1-implemented-in-tableau-20201
The route(“/info”) endpoint establishes the connection with Tableau by responding to a GET request with metadata in a JSON dictionary. It contains static information about the server and is up to the author to populate with the configurations used, as seen in the documentation. This endpoint also determines authentication requirements.
The route(“/evaluate”) function is the endpoint where Tableau POSTs the Julia script and data arguments as another JSON dictionary. This JSON payload, in turn, is parsed within Julia and evaluated. The output is then returned back to Tableau for visualization and analysis. As described in the API Reference page provided, this JSON payload is in a standardized format consisting of a “data” key and a “script” key, respectively with values depending on what was passed in the SCRIPT_*() calculated field like the following (here in Julia code):
Dict ( “script” => “Code from Calc Field in SCRIPT_*”, “data” => Dict (“arg1” => input_data1, “arg2” => input_data2))
Whats next for TabJulia
The current version doesn’t work for multiple lines of Julia code. With more time this would be my next short term goal for the framework started here.
It would also be nice to integrate many of TabPy’s features to make the Julia experience more efficient, effective and capable.
I was inspired by both Thomas Foldi’s blog “Tableau External Services API: Adding Haskell Expressions as Calculations” and Alex Blakemore, who I also want to thank for his guidance and support on this project.
Thank you for reading, please let me know your thoughts!