Built-in query language functions

Like constants and variables, there are many built-in functions that can be called from the query language with no additional imports or setup. These built-in functions should be used over Python or other user-defined functions in query strings for two reasons:

  • They are almost always more performant.
  • They handle null values gracefully.

For more on why, see The Python-Java boundary.

Built-in functions

Built-in functions range from simple mathematical functions to date-time arithmetic, string manipulation, and more.

The following query calculates the absolute value of a column using the built-in abs function:

The following query parses a column of strings containing integers into Java primitive int values using parseInt:

The following query uses the built-in and function to evaluate whether or not three different columns are all true:

Built-in functions gracefully handle null values as input. For example, the following example calls the built-in sin function on a column that contains null values:

This page does not provide a comprehensive list of all built-ins. For the complete list of functions built into the query language, see Auto-imported functions.

Add Java classes to the query library

To use a non-default Java class in a Deephaven Query Language (DQL) query string, you must first import the class into DQL using Python. For this, Deephaven offers the query_library module.

The following example adds the java.net.URL class to the query library then uses it in table operations.

You can also import static methods from a class into the query language to use them in table operations. The following example imports static methods from the java.lang.StrictMath class and uses them in table operations.

Note

import_static allows you to call methods without the class name. The class name is included in the examples below because methods of the same name also exist in the built-in io.deephaven.function.Numeric class.

In this case, you can no longer use just acos, exp, or any of the other method names that exist in both classes as it will be an ambiguous reference.