Array Remove
Definition
The arrayRemove
method allows you to add the ARRAY_REMOVE
function to the query. The ARRAY_REMOVE
function is used to remove all elements equal to the given value from the array (array must be one-dimensional).
Available methods
arrayRemove(KColumn kColumnArray, KColumn kColumnElement)
: Receives twoKColumn
orKTableColumn
which will be supplied to theARRAY_REMOVE
function.arrayRemove(KColumn kColumnArray, Object element)
: Receives aKColumn
orKTableColumn
and anObject
value which will be supplied to theARRAY_REMOVE
function.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example: (KColumn, KColumn)
Java code:
k
.select(
arrayRemove(arrayAgg(APP_USER.EMAIL), APP_USER.FIRST_NAME),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()), APP_USER.FIRST_NAME)
.multiple();
SQL generated:
SELECT
ARRAY_REMOVE(ARRAY_AGG(au.email), au.first_name),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE), au.first_name
Parameters:
- None
Example: (KColumn, Object)
Java code:
k
.select(
arrayRemove(arrayAgg(APP_USER.EMAIL), "EOF"),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()))
.multiple();
SQL generated:
SELECT
ARRAY_REMOVE(ARRAY_AGG(au.email), ?1),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE)
Parameters:
- ?1: "EOF"