Accessing Data

Finding Data Sources

The data loaded on your installation of Deephaven is managed by your system administrator. To learn about installed data, you can run the following commands in the Deephaven console:

  • To review a table listing all the available tables in the database, run:
     tables = db.getCatalog()
  • To find available namespaces, run:
     println db.getNamespaces()
  • To find available tables within a namespace, run:
     println db.getTableNames("<namespace>")
  • To see all of the column names and data types within a specific table, run:
     t = db.t("<namespace>","<tablename>").getMeta()

Note: The "autocomplete" feature can also be used to discover and insert namespaces and table names into your queries. See: Console > Autocomplete.

Data Table Types

Deephaven supports two types of tables: live tables and static tables.

  • Static tables (sometimes called "historical" tables) are regular data tables: they have fixed numbers of rows and columns, and contain fixed data.
  • Live tables (also known as "real-time" or "intraday") tables have a fixed number of columns, but new rows of data can be appended to the table over time.

The syntax is nearly identical when accessing both static and live data, but working with live data introduces additional performance concerns.

For more information, see Working with Live vs. Static Data.

Accessing Static Data

To retrieve static data, use the db.t() method, and pass the table's namespace and table name as arguments. The example below retrieves the table called exampleTable from a namespace called exampleNamespace, and stores the result under the variable t.

Note: exampleNamespace and exampleTable are not actual datasets available within Deephaven.

t = db.t("exampleNamespace", "exampleTable")

In many cases, the table to access is partitioned. When accessing a partitioned table, it is highly recommended to immediately filter the table by partition. The example below demonstrates how to filter exampleTable to the partition for March 15, 2017. (This example assumes that ExampleTable is partitioned by the Date column.)

t = db.t("exampleNamespace", "exampleTable").where("Date=`2017-03-15`")

Many tables are partitioned by date. In these cases, using a function to provide the date can produce a more robust query. The following example demonstrates how to access a table and filter to the previous business date (using New York time):

t = db.t("exampleNamespace", "exampleTable").where("Date=lastBusinessDateNy()")

Accessing Live Data

To retrieve live data, use the db.i() method instead of db.t(). The method parameters are the same. (The "i" in db.i stands for "intraday".)

Note: All live tables are partitioned tables, so any access to a live table should be immediately followed by a filter on the partitioning column.

The following line of code is an example of how to access live data for ExampleTable from March 15, 2017.

t = db.i("exampleNamespace", "exampleTable").where("Date=`2017-03-15`")

As with static data, it may be desirable to filter the data to a date determined by a function:

t = db.i("exampleNamespace", "exampleTable").where("Date=currentDateNy()")

Non-Updating Live Data

In some cases, a query requires the most recent data at the time of its initialization, but no subsequent updates. To disable updates when accessing live data, pass "false" as the third argument to db.i(). This will direct the query engine to not enable live updates for this table, which means new rows will never be appended to it.

t = db.i("exampleNamespace", "exampleTable", false).where("Date=currentDateNy()")


Last Updated: 20 August 2019 09:54 -06:00 UTC    Deephaven v.1.20180917

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