Skip to main content

convert (Function)

Converts the first input parameter according to the convertedTo parameter.

Syntax

<INT|LONG|DOUBLE|FLOAT|STRING|BOOL> convert(<INT|LONG|DOUBLE|FLOAT|STRING|BOOL|OBJECT> to.be.converted, <STRING> converted.to)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
to.be.convertedThis specifies the value to be converted.INT LONG DOUBLE FLOAT STRING BOOL OBJECTNoYes
converted.toA string constant parameter to which type the attribute need to be converted using one of the following strings values: int, long, float, double, string, bool.STRINGNoYes

Example 1

@info(name = 'query1')
INSERT INTO barStream
SELECT convert(temp, 'double') AS temp
FROM fooStream;

This query selects records from the fooStream collection and uses the convert function to convert the temp field to a double data type. The result is aliased as temp and inserted into the barStream.

Essentially, this query processes records in the fooStream and creates new records in the barStream with the temp field converted to a double data type.

Example 2

@info(name = 'query1')
INSERT INTO barStream
SELECT convert(temp, 'int') AS temp
FROM fooStream;

This query selects records from the fooStream and uses the convert function to convert the temp field to an int data type. The result is aliased as temp and inserted into the barStream.

Essentially, this query processes records in the fooStream and creates new records in the barStream with the temp field converted to an int data type.