Computes the square root of the input parameter. Input value can be a Decimal or Integer literal or a reference to a column containing numeric values. All generated values are non-negative.
Basic Usage
Numeric literal example:
derive type:single value:SQRT(25 )
Output: Generates a column containing the square root of 25, which is 5
.
Column reference example:
derive type:single value:SQRT(MyValue) as: 'sqroot_MyValue'
Output: Generates the new sqroot_myValue
column containing the square root of the values of the MyValue
column.
Syntax and Arguments
derive type:single value:SQRT(numeric_value)
Argument | Required? | Data Type | Description |
---|---|---|---|
numeric_value | Y | string, decimal, or integer | Name of column or Decimal or Integer literal to apply to the function |
For more information on syntax standards, see Language Documentation Syntax Notes.
numeric_value
Name of the column or numeric literal whose values are used to compute the square root.
NOTE: Negative input values generate null output values.
- Missing input values generate missing results.
- Literal numeric values should not be quoted.
- Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | String (column reference) or Integer or Decimal literal | 25 |
Tip: For additional examples, see Common Tasks.
Examples
Example - Pythagorean Theorem
POW
and SQRT
functions work together to compute the hypotenuse of a right triangle using the Pythagorean theorem.POW
- X Y . In this case, 10 to the power of the previous one. See POW Function .SQRT
- computes the square root of the input value. See SQRT Function.
The Pythagorean theorem states that in a right triangle the length of each side (x,y) and of the hypotenuse (z) can be represented as the following:
z2 = x 2 + y 2
Therefore, the length of z can be expressed as the following:
z = sqrt(x 2 + y 2 )
For more information on the Pythagorean theorem, see https://en.wikipedia.org/wiki/Pythagorean_theorem.Source:
The dataset below contains values for x and y:
X | Y |
---|---|
3 | 4 |
4 | 9 |
8 | 10 |
30 | 40 |
Transform:
You can use the following transform to generate values for z2.
NOTE: Do not add this step to your recipe right now.
derive type:single value:(POW(x,2) + POW(y,2)) as:'Z'
SQRT
function:
derive type:single value:SQRT((POW(x,2) + POW(y,2))) as: 'Z'
X | Y | Z |
---|---|---|
3 | 4 | 5 |
4 | 9 | 9.848857801796104 |
8 | 10 | 12.806248474865697 |
30 | 40 | 50 |
This page has no comments.