String To Array
Definition
The stringToArray
method allows you to add the STRING_TO_ARRAY
function to the query. The STRING_TO_ARRAY
function is used to splits string into array elements using supplied delimiter and optional null string.
Available methods
stringToArray(KBaseColumnCastable kBaseColumnCastable, String delimiter)
: Receives aKColumn
,KTableColumn
or aValues
and aString
value which will be supplied to theSTRING_TO_ARRAY
function.stringToArray(KBaseColumnCastable kBaseColumnCastable, String delimiter, String nullString)
: Receives aKColumn
,KTableColumn
or aValues
and twoString
values which will be supplied to theSTRING_TO_ARRAY
function.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example: (KColumn, String)
Java code:
k
.select(
stringToArray(APP_USER.EMAIL, "@"),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
STRING_TO_ARRAY(au.email, ?1),
CAST(au.created_at AS DATE)
FROM app_user au
Parameters:
- ?1: "@"
Example: (KColumn, String, String)
Java code:
k
.select(
stringToArray(APP_USER.EMAIL, "@", "yopmail.com"),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
STRING_TO_ARRAY(au.email, ?1, ?2),
CAST(au.created_at AS DATE)
FROM app_user au
Parameters:
- ?1: "@"
- ?1: "yopmail.com"