Array Ndims
Definition
The arrayNdims
method allows you to add the ARRAY_NDIMS
function to the query. The ARRAY_NDIMS
function is used to return the number of dimensions of the array.
There are 2 ways to call this method:
1. Calling from a KColumn
or a KTableColumn
The only one method available to use this functionality calling from a KColumn
or a KTableColumn
is:
arrayNdims()
: It does not receive any parameters. TheKColumn
orKTableColumn
that invokes the method will be the one supplied to theARRAY_NDIMS
function.
Example
Java code:
k
.select(
APP_USER.EMAIL.arrayAgg().arrayNdims(),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()))
.multiple();
SQL generated:
SELECT
ARRAY_NDIMS(ARRAY_AGG(au.email)),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE)
Parameters:
- None
2. Calling from the KFunction
class
The only one method available to use this functionality calling from the KFunction
class is:
arrayNdims(KColumn kColumnArray)
: Receives aKColumn
or aKTableColumn
which will be supplied to theARRAY_NDIMS
function.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example
Java code:
k
.select(
arrayNdims(arrayAgg(APP_USER.EMAIL)),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()))
.multiple();
SQL generated:
SELECT
ARRAY_NDIMS(ARRAY_AGG(au.email)),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE)
Parameters:
- None