Locking Column Order in a Table

Designated columns in Deephaven tables can be "locked" in place at the start or the end of the column order. This enables the query author to ensure a consistent experience for all authorized users of that table. This feature uses the .layoutHints method.

For example, the image below shows a table with eight columns. Four of the columns have a lock icon in the column header. The appearance of that icon means those four columns are locked in place. USym and Timestamp are locked to the left side of the table, and Sym and SecurityType are locked to the right side of the table. Moreover, the tab for the table also presents a "no-write" icon, which means the layout of this table cannot be saved by other users.

Locking columns in starting or ending order in a table is accomplished in the query language by importing the LayoutHintBuilder class and then setting one or more of the following three parameters:

  • atFront() – This method locks one or more columns to the beginning of the table. Column names are used as the argument(s).
  • atEnd() – This method locks one or more columns to the end of the table. Column names are used as the argument(s).
  • savedLayouts() – This parameter impacts users with whom this table is shared.  When set to true, other users can rearrange the non-locked columns and then save their own layout for the specified table.  When set to false, other users can rearrange the non-locked columns, but they cannot save the new column order. When the table is opened again, the column order will revert to the default order specified by the query author.

For example, the table shown in the previous screenshot was created with the following query:

import com.illumon.iris.db.tables.utils.LayoutHintBuilder
t1=db.t("LearnIris", "StockQuotes").where("Date=`2017-08-25`")
t2=t1.update().layoutHints(LayoutHintBuilder
	.get()
	.atFront("USym","Timestamp")
	.atEnd("Sym", "SecurityType")
	.savedLayouts(false)
	)
importjava("com.illumon.iris.db.tables.utils.LayoutHintBuilder")
t3=db.t("LearnIris", "StockQuotes").where("Date=`2017-08-25`")
t4=t3.update(java_array("java.lang.String", [])).layoutHints(LayoutHintBuilder.get().atFront("USym","Timestamp").atEnd("Sym", "SecurityType").savedLayouts(False))
				
  • The first line of the query tells Deephaven to import the LayoutHintBuilder class, which is needed for the query to run properly.
  • The second line of the query generates the t1 table using data from the StockQuotes table in the LearnIris namespace, filtered to August 25, 2017.
  • The third line of the query creates a new instance of the LayoutHintBuilder using the get() method, then creates the table t2, which locks the USym and Timestamp columns to the front of the table, and Sym and SecurityType to the end of the table, and specifies that no changes to the layout can be saved by authorized users upon closing and reopening the table.

To ensure the locked column(s) are applied only on the t2 table, a select, update, updateView or where operation must be included before the .layoutHints() operation in the query. This enables Deephaven to create the t2 table as an individual object before continuing to the next method. 


Last Updated: 06 July 2020 14:35 -04:00 UTC    Deephaven v.1.20190117  (See other versions)

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