Skip to main content

sqrt (Function)

This function returns the square-root of the given value. It wraps the java.lang.Math.sqrt() function.

Syntax

<DOUBLE> math:sqrt(<INT|LONG|FLOAT|DOUBLE> p1)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
p1The value of the parameter whose square-root value should be found.INT LONG FLOAT DOUBLENoYes

Example 1

CREATE STREAM InValueStream (inValue double);

@info(name = 'calculateSquareRoot')
INSERT INTO OutMediationStream
SELECT math:sqrt(inValue) AS sqrtValue
FROM InValueStream;

The calculateSquareRoot query processes the input stream InValueStream, which contains a single field inValue. For each event in the input stream, the query calculates the square-root value of the inValue using the math:sqrt() function.

The math:sqrt() function takes the given inValue and returns the corresponding square-root value.

The calculated square-root value is aliased as sqrtValue, and the output stream OutMediationStream contains this value. This query processes the input stream events and forwards the resulting square-root values to the output stream for further processing or analysis.

For example, if inValue is 4, the sqrtValue will be 2.