Deephaven Quick Start Guide

The Quick Start Guide is designed to be a very short exercise to familiarize new users with the Deephaven interface, provide examples of using the Deephaven query language to generate tables and plots, save queries, and build a customized workspace.

Prerequisites

  • Deephaven needs to be installed for your enterprise.
  • To use Deephaven Classic, the Deephaven Launcher application needs to be installed on your PC, with an instance configured to access the stored data.
Please consult with your system administrator if assistance is needed.

Open Deephaven

Working with Dashboards

Note: This step applies to Deephaven on the web only.

Dashboards are customized collections of content including tables, plots and/or sets of nested panels. You can manipulate tables and plots in dashboards by dragging and dropping, as you’d expect. Using, creating, and sharing dashboards is fundamental to the value of the experience.

Step 1 - Create a Dashboard

Let's create our own workspace. Select New Dashboard to open an empty dashboard window called "Untitled".

Right-click the tab to rename your dashboard - we'll name ours "Demo Dashboard".

Step 2 - Add Content

You can add content to your dashboard using the Panels menu. This menu presents a list of Persistent Queries available to you. Each of these generate tables and/or plots that you can add to your dashboard(s) or consume via APIs.

For example, select the query named "LearnDeephavenPQ", and then select the name of the table or plot from the list to add it to your dashboard layout. In this case, we'll select the "StockQuotes" table.

The table will then be added to the dashboard.

You can repeat this workflow to add as many tables and plots to the dashboard as you'd like, including those from different Persistent Queries.

Go back to the Panels menu and add a plot called "RetailPlot" to the Dashboard. This is a OneClick plot, and we'll see what it can do in the next step.

Step 3 - Manipulate the Data

As you can see when you added RetailPlot to your Dashboard, Deephaven prompts you to add a filter in order for the plot to draw. We've built instructions like these into the interface to help you learn how to use Deephaven as you explore and try your own analyses.

Click the blue Add Input Filters button and an Input Filter for the appropriate column will be added to your workspace (in this case, USym as configured in the underlying query. More on that later). Type a USym value - e.g., GOOG or AAPL - and not only will the plot draw those values, but the StockQuotes table open in your dashboard will also filter on the USym column accordingly.

What if you want to filter the table only? Right-click any column header to check out additional filter and sorting options.

For now, choose Quick Filters to open the Quick Filters bar above the StockQuotes table's column headers. You'll see a field above each column - type a value to instantly filter that column, as shown below:

Don't know the values off the top of your head, or you want finer grained control? Click the funnel icon in the Quick Filters bar to pull up the Advanced Filters.

The Advanced Filters dialog provides more options for the filter type, and also auto-populates the column values, allowing you to search or scroll through the options to select one or multiple values.

Step 4 - Make a Plot

In Step 2, we opened a plot from the Panels menu. You can also make plots directly from the Chart Builder feature.

In the table containing the data you want to plot, click the hamburger icon in the upper right corner.

This will open the Table Options menu. Select Chart Builder.

The Chart Builder interface allows you to choose one of the five available chart types, and configure the applicable axis values. For this example, choose Timestamp as the X-Axis value and BidSize as the Series value.

Click Create and the new plot will open in its own tab next to RetailPlot.

Want to move these panels around? Move on to Step 5.

Step 5 - Customize Your Workspace

The tables and plots open in default positions, but you can move and/or resize any panel.

For instance, if you wanted BidSize by Timestamp to be larger, you can use your cursor to expand the panel size, or drag-and-drop panels to new locations. You could move your Input Filter next to StockQuotes and shrink its size so it doesn't take up so much real estate, as shown below:

Your layout retains your changes when you close it. To re-open your Dashboard or another existing Dashboard, go back to the New+ tab and choose an item from the All Dashboards list.

Working with Code Studios and Queries

A Code Studio is a workspace for writing queries and code to interrogate and manipulate data. Multiple Code Studios may be open simultaneously, including those using different programming languages. This is especially beneficial if you have a variety of independent, ad hoc analyses or development projects underway at the same time.

Note: These steps can be performed in Deephaven Classic or Deephaven on the web.

Step 1 - Launch a Code Studio

Navigate to the Code Studio tab on the left of your navigation bar:

(You can also launch a new Code Studio from the +New tab by selecting the New Code Studio button.)

Click the Connect button. The default settings will be fine for this exercise. We'll be using Python in these examples.

Step 2 - Access Your Data

Deephaven uses data stored in tables. These tables are organized by namespaces. This is analogous to the way you store information on your computer. Just as you might use folders (or directories) to hold individual files, Deephaven uses namespaces to hold individual tables.

You can use the Deephaven Query Language to write scripts that will immediately render tables and plots in the console. This real-time feedback loop (on all sorts of data) is great for on-the-fly analysis, debugging, and development.

To access tables in Deephaven, you need to know:

  • where the table is located (the name of the namespace), and
  • the name of the table

Let's see how the Code Studio works by writing a simple query. For this exercise we are going to access the namespace called "LearnDeephaven", and open a table called "StockTrades". (Note: This configuration should be included with the default Deephaven installation. Contact your system administrator if it is not.)

Either copy and paste or type the following query immediately after the flashing cursor in the Console section of your new Code Studio:

table1 = db.t("LearnDeephaven","StockTrades")

This is a Deephaven query. Go to our Writing Queries section for more details about the Deephaven Query Language, but the following diagram summarizes what the query is asking Deephaven to do:

Press Enter or Return on your keyboard to run the query in Deephaven.

A new tabbed panel named table1 will appear in your workspace:

The table you just accessed is partitioned. This means the table is organized and grouped into different smaller segments. By organizing a table like this, the computing power needed for analysis can be applied more efficiently, especially when your table has millions or billions of rows of data.

In this case, the table is partitioned by the date shown in the first column. Since the table is large, Deephaven opens the table to a single partition (2017-08-25). You can choose Ignore & Fetch All to load the entire table, or select a different partition:

For this exercise, click Append Query at the right to update the query to automatically filter on that date. This will reload table1 with a filter (using the .where method) on the Date column as visible in your console.

Step 3 - Manipulate the Data

Now that we have a table loaded into the Deephaven console, we can further manipulate the data to serve our needs. For example, we can filter the data to include only certain categories, values or other aspects. We can add new columns or remove columns we don't need. Or, we can sort, group or aggregate the data, or join the data in this table with data from another table. The Deephaven Query Language provides many methods for manipulating the data further. However, since we're just getting started, we'll stick with something relatively simple.

The table now holds quantitative information about the individual trades for each of 10 different financial securities (AAPL, AXP, BAC, CSCO, GOOG, IBM, INTC, MSFT, PFE, XOM). If you scroll in the window holding the table, you can start to get a sense of the large volume of data the table holds. When you clicked Append Query, a new query with a filter applied was produced to show only the data for August 25, 2017.

table1=table1.where("Date=`2017-08-25`")

We can reduce the dataset still further, using an additional .where filter. Copy and paste, or re-type, the following query into the Console:

table2=table1.where("Date=`2017-08-25`" , "Sym = `XOM`")

The following diagram illustrates what you are asking Deephaven to do:

When this query is run in Deephaven, a new tab for table2 appears. If you scroll through the table, you'll see it only contains the data for when the value XOM is contained in the column titled Sym. The data has now been reduced to only 38,387 rows (hover over any column header to generate these statistics):

You can accomplish the same result by using shortcuts within the user interface, as we did when working with Dashboards. Right-click any column header or within the table data to pull up those options.

Column Header Context Menu

Table Data Context Menu
(Note: initiated from a XOM cell in the Sym column)

Step 4 - Make a Plot

We showed you how to make a plot using the Chart Builder when working in Dashboards. The Table Options menu is available in Code Studios, but you can also use the Deephaven Query Language.

In the previous step, we filtered the table to show only one day's worth of data for only one ticker symbol from the Sym column. Let's plot that data to more easily visualize any trend or pattern it may show. Here's the query to plot the price of that ticker symbol over the course of that one day:

from deephaven import Plot
plotXOM = Plot.plot("ExxonMobil", table2, "Timestamp", "Last").show()

The following diagram summarizes the components of this query:

Copy the query above and then paste it into the Deephaven.

After this query runs in Deephaven, a new panel titled plotXOM appears in the lower part of the console window.  This panel shows a plot that charts the variation in the price of ExxonMobil stock over the course of one day.

Step 5 - Customize your Workspace

The plot draws to the right of the two tables, but you can also drag and drop the panel to reposition the chart in your workspace, as shown below, where plotXOM is moved from its own panel to join the nested panel set:

Close any panel in your workspace by clicking the X in its tab:

If you close table1, you can easily reopen the table again in the same session by clicking the blue button with its variable name in the console:

And remember, you can also resize any panel by placing your cursor at one of its borders and dragging-and-dropping to make your adjustments. Below, we shrink the console panel:

As with Dashboards, your layout will be saved. You can also rename your Code Studio tab and access it again from the New+ button and the All Dashboards list.

Creating and Saving Persistent Queries

So far, you've accessed data, filtered the data, saved the data and made a plot. In the Code Studio, you completed those steps by using queries in the Deephaven console. What if you wanted to save those queries so you could use them later? Or maybe you want to share those queries or the tables generated by the queries with other individuals or teams within your enterprise. This is easy to do by making your query persistent - meaning the query is saved and stored.

There are a number of ways to create a persistent query, so you should review the Query Configuration section of our documentation. We'll review the primary method here.


Last Updated: 16 February 2021 18:06 -04:00 UTC    Deephaven v.1.20200928  (See other versions)

Deephaven Documentation     Copyright 2016-2020  Deephaven Data Labs, LLC     All Rights Reserved