public class Arithmetic extends Object
The provided functions are polymorphic. That is, the type of the output depends on the types of the inputs. Arithmetic types follow the behavior of the analogous operations on Java primitive numeric types; the result is always of the widest of the input types.
ScalarValuedFunction
,
DeriveFields
Constructor and Description |
---|
Arithmetic() |
Modifier and Type | Method and Description |
---|---|
static ScalarValuedFunction |
add(double leftValue,
ScalarValuedFunction rightExpr)
Builds an expression adding a constant to the value of the specified
subexpression.
|
static ScalarValuedFunction |
add(double leftValue,
String rightField)
Builds an expression adding a constant to the value of the specified field.
|
static ScalarValuedFunction |
add(ScalarValuedFunction leftExpr,
double rightValue)
Builds an expression adding a constant to the value of the specified
subexpression.
|
static ScalarValuedFunction |
add(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds an expression adding the values of the two specified subexpressions.
|
static ScalarValuedFunction |
add(ScalarValuedFunction leftExpr,
String rightField)
Builds an expression adding a the value of the specified field and
subexpression.
|
static ScalarValuedFunction |
add(String leftField,
double rightValue)
Builds an expression adding a constant to the value of the specified field.
|
static ScalarValuedFunction |
add(String leftField,
ScalarValuedFunction rightExpr)
Builds an expression adding a the value of the specified field and
subexpression.
|
static ScalarValuedFunction |
add(String leftField,
String rightField)
Builds an expression adding the values of the two specified fields.
|
static ScalarValuedFunction |
div(double leftValue,
ScalarValuedFunction rightExpr)
Builds an expression dividing a constant by the value of the specified subexpression.
|
static ScalarValuedFunction |
div(double leftValue,
String rightField)
Builds an expression dividing a constant by the value of the specified field.
|
static ScalarValuedFunction |
div(ScalarValuedFunction leftExpr,
double rightValue)
Builds an expression dividing the value of the specified subexpression by a constant.
|
static ScalarValuedFunction |
div(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds an expression dividing the values of the two specified subexpressions.
|
static ScalarValuedFunction |
div(ScalarValuedFunction leftExpr,
String rightField)
Builds an expression dividing a subexpression by the value of the specified field.
|
static ScalarValuedFunction |
div(String leftField,
double rightValue)
Builds an expression dividing the value of the specified field by a constant.
|
static ScalarValuedFunction |
div(String leftField,
ScalarValuedFunction rightExpr)
Builds an expression dividing the value of the specified field by a subexpression.
|
static ScalarValuedFunction |
div(String leftField,
String rightField)
Builds an expression dividing the values of the two specified fields.
|
static ScalarValuedFunction |
mult(double leftValue,
ScalarValuedFunction rightExpr)
Builds an expression multiplying the value of the specified subexpression by a constant.
|
static ScalarValuedFunction |
mult(double leftValue,
String rightField)
Builds an expression multiplying the value of the specified field by a constant.
|
static ScalarValuedFunction |
mult(ScalarValuedFunction leftExpr,
double rightValue)
Builds an expression multiplying the value of the specified subexpression by a constant.
|
static ScalarValuedFunction |
mult(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds an expression multiplying the values of the two specified subexpressions.
|
static ScalarValuedFunction |
mult(ScalarValuedFunction leftExpr,
String rightField)
Builds an expression multiplying the values of the specified field and subexpression.
|
static ScalarValuedFunction |
mult(String leftField,
double rightValue)
Builds an expression multiplying the value of the specified field by a constant.
|
static ScalarValuedFunction |
mult(String leftField,
ScalarValuedFunction rightExpr)
Builds an expression multiplying the values of the specified field and subexpression.
|
static ScalarValuedFunction |
mult(String leftField,
String rightField)
Builds an expression multiplying the values of the two specified fields.
|
static ScalarValuedFunction |
neg(ScalarValuedFunction expr)
Builds an expression negating the value of the specified subexpression.
|
static ScalarValuedFunction |
neg(String field)
Builds an expression negating the value of the specified field.
|
static ScalarValuedFunction |
remainder(double leftValue,
ScalarValuedFunction rightExpr)
Builds an expression dividing a constant by the value of the specified subexpression and returning the remainder.
|
static ScalarValuedFunction |
remainder(double leftValue,
String rightField)
Builds an expression dividing a constant by the value of the specified field and returning the remainder.
|
static ScalarValuedFunction |
remainder(ScalarValuedFunction leftExpr,
double rightValue)
Builds an expression dividing the value of the specified subexpression by a constant and returning the remainder.
|
static ScalarValuedFunction |
remainder(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds an expression dividing the values of the two specified subexpressions and returning the remainder.
|
static ScalarValuedFunction |
remainder(ScalarValuedFunction leftExpr,
String rightField)
Builds an expression dividing a subexpression by the value of the specified field and returning the remainder.
|
static ScalarValuedFunction |
remainder(String leftField,
double rightValue)
Builds an expression dividing the value of the specified field by a constant and returning the remainder.
|
static ScalarValuedFunction |
remainder(String leftField,
ScalarValuedFunction rightExpr)
Builds an expression dividing the value of the specified field by a subexpression and returning the remainder.
|
static ScalarValuedFunction |
remainder(String leftField,
String rightField)
Builds an expression dividing the values of the two specified fields and returning the remainder.
|
static ScalarValuedFunction |
scaledDiv(BigDecimal leftValue,
String rightField,
int scale)
Builds an expression dividing a constant by the value of the specified subexpression to the specified scale.
|
static ScalarValuedFunction |
scaledDiv(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr,
int scale)
Builds an expression dividing the values of the two specified subexpressions to the specified scale.
|
static ScalarValuedFunction |
scaledDiv(ScalarValuedFunction leftExpr,
String rightField,
int scale)
Builds an expression dividing a subexpression by the value of the specified field to the specified scale.
|
static ScalarValuedFunction |
scaledDiv(String leftField,
BigDecimal rightValue,
int scale)
Builds an expression dividing the value of the specified subexpression by a constant to the specified scale.
|
static ScalarValuedFunction |
scaledDiv(String leftField,
ScalarValuedFunction rightExpr,
int scale)
Builds an expression dividing the value of the specified field by a subexpression to the specified scale.
|
static ScalarValuedFunction |
scaledDiv(String leftField,
String rightField,
int scale)
Builds an expression dividing the values of the two specified fields to the specified scale.
|
static ScalarValuedFunction |
sub(double leftValue,
ScalarValuedFunction rightExpr)
Builds an expression subtracting the value of the specified subexpression from a constant.
|
static ScalarValuedFunction |
sub(double leftValue,
String rightField)
Builds an expression subtracting the value of the specified field from a constant.
|
static ScalarValuedFunction |
sub(ScalarValuedFunction leftExpr,
double rightValue)
Builds an expression subtracting a constant from the value of the specified subexpression.
|
static ScalarValuedFunction |
sub(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds an expression subtracting the values of the two specified subexpressions.
|
static ScalarValuedFunction |
sub(ScalarValuedFunction leftExpr,
String rightField)
Builds an expression subtracting the value of the specified field from a subexpression.
|
static ScalarValuedFunction |
sub(String leftField,
double rightValue)
Builds an expression subtracting a constant from the value of the specified field.
|
static ScalarValuedFunction |
sub(String leftField,
ScalarValuedFunction rightExpr)
Builds an expression subtracting a subexpression from the value of the specified field.
|
static ScalarValuedFunction |
sub(String leftField,
String rightField)
Builds an expression subtracting the values of the two specified fields.
|
public static ScalarValuedFunction neg(String field)
null
, the result is null
.field
- the record field value to negatepublic static ScalarValuedFunction neg(ScalarValuedFunction expr)
null
, the result is null
.expr
- the numeric expression to negatepublic static ScalarValuedFunction add(String leftField, String rightField)
null
, the result is null
.leftField
- the record field value on the left side of the additionrightField
- the record field value on the right side of the additionpublic static ScalarValuedFunction add(String leftField, double rightValue)
null
, the result is null
.leftField
- the record field value on the left side of the additionrightValue
- the constant value on the right side of the additionpublic static ScalarValuedFunction add(double leftValue, String rightField)
null
, the result is null
.leftValue
- the constant value on the left side of the additionrightField
- the record field value on the right side of the additionpublic static ScalarValuedFunction add(String leftField, ScalarValuedFunction rightExpr)
null
, the result is null
.leftField
- the record field value on the left side of the additionrightExpr
- the numeric expression on the right side of the additionpublic static ScalarValuedFunction add(ScalarValuedFunction leftExpr, String rightField)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the additionrightField
- the record field value on the right side of the additionpublic static ScalarValuedFunction add(double leftValue, ScalarValuedFunction rightExpr)
null
, the result is null
.leftValue
- the constant value on the left side of the additionrightExpr
- the numeric expression on the right side of the additionpublic static ScalarValuedFunction add(ScalarValuedFunction leftExpr, double rightValue)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the additionrightValue
- the constant value on the right side of the additionpublic static ScalarValuedFunction add(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the additionrightExpr
- the numeric expression on the right side of the additionpublic static ScalarValuedFunction sub(String leftField, String rightField)
null
, the result is null
.leftField
- the record field value on the left side of the subtractionrightField
- the record field value on the right side of the subtractionpublic static ScalarValuedFunction sub(String leftField, double rightValue)
null
, the result is null
.leftField
- the record field value on the left side of the subtractionrightValue
- the constant value on the right side of the subtractionpublic static ScalarValuedFunction sub(double leftValue, String rightField)
null
, the result is null
.leftValue
- the constant value on the left side of the subtractionrightField
- the record field value on the right side of the subtractionpublic static ScalarValuedFunction sub(String leftField, ScalarValuedFunction rightExpr)
null
, the result is null
.leftField
- the record field value on the left side of the subtractionrightExpr
- the numeric expression on the right side of the subtractionpublic static ScalarValuedFunction sub(ScalarValuedFunction leftExpr, String rightField)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the subtractionrightField
- the record field value on the right side of the subtractionpublic static ScalarValuedFunction sub(double leftValue, ScalarValuedFunction rightExpr)
null
, the result is null
.leftValue
- the constant value on the left side of the subtractionrightExpr
- the numeric expression on the right side of the subtractionpublic static ScalarValuedFunction sub(ScalarValuedFunction leftExpr, double rightValue)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the subtractionrightValue
- the constant value on the right side of the subtractionpublic static ScalarValuedFunction sub(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the subtractionrightExpr
- the numeric expression on the right side of the subtractionpublic static ScalarValuedFunction mult(String leftField, String rightField)
null
, the result is null
.leftField
- the record field value on the left side of the multiplicationrightField
- the record field value on the right side of the multiplicationpublic static ScalarValuedFunction mult(String leftField, double rightValue)
null
, the result is null
.leftField
- the record field value on the left side of the multiplicationrightValue
- the constant value on the right side of the multiplicationpublic static ScalarValuedFunction mult(double leftValue, String rightField)
null
, the result is null
.rightField
- the record field value on the right side of the multiplicationleftValue
- the constant value on the left side of the multiplicationpublic static ScalarValuedFunction mult(String leftField, ScalarValuedFunction rightExpr)
null
, the result is null
.leftField
- the record field value on the left side of the multiplicationrightExpr
- the numeric expression on the right side of the multiplicationpublic static ScalarValuedFunction mult(ScalarValuedFunction leftExpr, String rightField)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the multiplicationrightField
- the record field value on the right side of the multiplicationpublic static ScalarValuedFunction mult(double leftValue, ScalarValuedFunction rightExpr)
null
, the result is null
.leftValue
- the constant value on the left side of the multiplicationrightExpr
- the numeric expression on the right side of the multiplicationpublic static ScalarValuedFunction mult(ScalarValuedFunction leftExpr, double rightValue)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the multiplicationrightValue
- the constant value on the right side of the multiplicationpublic static ScalarValuedFunction mult(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
, the result is null
.leftExpr
- the numeric expression on the left side of the multiplicationrightExpr
- the numeric expression on the right side of the multiplicationpublic static ScalarValuedFunction div(String leftField, String rightField)
null
or if the divisor evaluates to 0
,
the result is null
.leftField
- the record field value on the left side of the divisionrightField
- the record field value on the right side of the divisionpublic static ScalarValuedFunction div(String leftField, double rightValue)
null
, the result is null
.leftField
- the record field value on the left side of the divisionrightValue
- the constant value on the right side of the divisionpublic static ScalarValuedFunction div(double leftValue, String rightField)
null
, the result is null
.leftValue
- the constant value on the left side of the divisionrightField
- the record field value on the right side of the divisionpublic static ScalarValuedFunction div(String leftField, ScalarValuedFunction rightExpr)
null
or if the divisor evaluates to 0
, the result is null
.leftField
- the record field value on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionpublic static ScalarValuedFunction div(ScalarValuedFunction leftExpr, String rightField)
null
or the divisor evaluates to 0
, the result is null
.leftExpr
- the numeric expression on the left side of the divisionrightField
- the record field value on the right side of the divisionpublic static ScalarValuedFunction div(double leftValue, ScalarValuedFunction rightExpr)
null
or 0
, the result is null
.leftValue
- the constant value on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionpublic static ScalarValuedFunction div(ScalarValuedFunction leftExpr, double rightValue)
leftExpr
- the numeric expression on the left side of the divisionrightValue
- the constant value on the right side of the divisionpublic static ScalarValuedFunction div(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
or if the divisor evaluates to
0
, the result is null
.
Division will be done as appropriate for the result type;
if both inputs are integer types, integer division will be used. To force
floating point division in this case, convert one expression to floating point
using Conversions.asDouble(ScalarValuedFunction)
or
Conversions.asFloat(ScalarValuedFunction)
.
leftExpr
- the numeric expression on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionpublic static ScalarValuedFunction scaledDiv(String leftField, String rightField, int scale)
null
or if the divisor evaluates to 0
,
the result is null
.leftField
- the record field value on the left side of the divisionrightField
- the record field value on the right side of the divisionscale
- the scale, or precision, of the resultpublic static ScalarValuedFunction scaledDiv(String leftField, BigDecimal rightValue, int scale)
leftExpr
- the numeric expression on the left side of the divisionrightValue
- the constant value on the right side of the divisionscale
- the scale, or precision, of the resultpublic static ScalarValuedFunction scaledDiv(BigDecimal leftValue, String rightField, int scale)
null
or 0
, the result is null
.leftValue
- the constant value on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionscale
- the scale, or precision, of the resultpublic static ScalarValuedFunction scaledDiv(String leftField, ScalarValuedFunction rightExpr, int scale)
null
or if the divisor evaluates to 0
, the result is null
.leftField
- the record field value on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionscale
- the scale, or precision, of the resultpublic static ScalarValuedFunction scaledDiv(ScalarValuedFunction leftExpr, String rightField, int scale)
null
or the divisor evaluates to 0
, the result is null
.leftExpr
- the numeric expression on the left side of the divisionrightField
- the record field value on the right side of the divisionscale
- the scale, or precision, of the resultpublic static ScalarValuedFunction scaledDiv(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr, int scale)
null
or if the divisor evaluates to
0
, the result is null
.leftExpr
- the numeric expression on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionscale
- the scale, or precision, of the resultpublic static ScalarValuedFunction remainder(String leftField, String rightField)
null
or if the divisor evaluates to 0
,
the result is null
.leftField
- the record field value on the left side of the divisionrightField
- the record field value on the right side of the divisionpublic static ScalarValuedFunction remainder(String leftField, double rightValue)
null
, the result is null
.leftField
- the record field value on the left side of the divisionrightValue
- the constant value on the right side of the divisionpublic static ScalarValuedFunction remainder(double leftValue, String rightField)
null
, the result is null
.leftValue
- the constant value on the left side of the divisionrightField
- the record field value on the right side of the divisionpublic static ScalarValuedFunction remainder(String leftField, ScalarValuedFunction rightExpr)
null
or if the divisor evaluates to 0
, the result is null
.leftField
- the record field value on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionpublic static ScalarValuedFunction remainder(ScalarValuedFunction leftExpr, String rightField)
null
or the divisor evaluates to 0
, the result is null
.leftExpr
- the numeric expression on the left side of the divisionrightField
- the record field value on the right side of the divisionpublic static ScalarValuedFunction remainder(double leftValue, ScalarValuedFunction rightExpr)
null
or 0
, the result is null
.leftValue
- the constant value on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionpublic static ScalarValuedFunction remainder(ScalarValuedFunction leftExpr, double rightValue)
leftExpr
- the numeric expression on the left side of the divisionrightValue
- the constant value on the right side of the divisionpublic static ScalarValuedFunction remainder(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
or if the divisor evaluates to
0
, the result is null
.
Division will be done as appropriate for the result type;
if both inputs are integer types, integer division will be used. To force
floating point division in this case, convert one expression to floating point
using Conversions.asDouble(ScalarValuedFunction)
or
Conversions.asFloat(ScalarValuedFunction)
.
leftExpr
- the numeric expression on the left side of the divisionrightExpr
- the numeric expression on the right side of the divisionCopyright © 2020 Actian Corporation. All rights reserved.