Create a table with newTable
This guide will show you how to create a new, in-memory user table.
Deephaven stores data in tables, which are composed of rows and columns of data. Methods such as intCol
create a column of data. Each data column contains only one type of data, for example, int
. The newTable
method creates a new table from one or more data columns.
Here, we will make a simple two-column table. Copy and run the following code in your console:
result = newTable(
stringCol("NameOfStringCol", "Data String 1", 'Data String 2', "Data String 3"),
intCol("NameOfIntCol", 4, 5, 6)
)
- result
This produces a table with a String column, an integer column, and three rows.
We will walk you through the query step-by-step.
Groovy users need to import the TableTools package.
- We are using the
newTable
method. Its arguments will define our column names, types, and contents. - We define a string column using the method
stringCol
:- the first argument is the column name,
NameOfStringCol
. Column names are typically capitalized. - the next arguments are the column contents, written as a comma-separated list. Since these are String values, they are enclosed in quotation marks.
- the first argument is the column name,
- We define a second column using the method
intCol
:- the first argument is the column name,
NameOfIntCol
- the next arguments are the column contents, written as a comma-separated list of integers.
- the first argument is the column name,
Now that you have data in columns, it can be graphically manipulated in several ways in the UI. For instance, right-clicking a column header or the table data opens menus with options to filter, sort, and copy content.