Special Functions

This page covers functions for referencing and parameterizing collections and field names in Rockset.

TABLE

TABLE function takes an string or an array of strings to construct a collection name.

For single string parameter, result collection name use the default workspace name with the string as it's table name.

For a string array parameter, result collection name construct the workspace name using the array of strings except the last one. The last string in the array will be used as table name.

Parameters used by TABLE function can be query parameters, so user can parameterize which collection to read from or write to for their Query Lambdas.

For example:

SELECT a FROM TABLE(['workspace', 'foo'])

is an equivalent query to:

SELECT a FROM workspace.foo

For a single string parameter:

SELECT a FROM TABLE('foo')

is an equivalent query to:

SELECT a FROM foo

FIELD

FIELD function takes 1 or 2 strings as argument to construct a field reference.

For single string parameter, result field reference will be a field with the string as name in the implicit relational.

For 2 strings parameters, result field reference use the first string as referenced relational and second string as field name.

Parameters used by FIELD function can be query parameters, so user can parameterize field references used by their Query Lambdas.

For example:

SELECT FIELD('foo', 'a.x') AS x FROM foo

is an equivalent query to:

SELECT foo.a.x FROM foo
SELECT * FROM foo WHERE FIELD('c') = 42

is an equivalent query to:

SELECT * FROM foo WHERE c = 42

For queries referencing more than 1 relation:

SELECT  
    FIELD('foo', 'a') AS a  
FROM  
    foo  
    JOIN bar ON foo.x = FIELD('bar', 'x')

is an equivalent query to:

SELECT  
    foo.a  
FROM  
    foo  
    JOIN bar ON foo.x = bar.x

Note the FIELD function won't generate default field alias. Field alias need to be explicitly set by AS …