Skip to content

Commit

Permalink
Updated Arithmetic functions from old engine to new engine (#235)
Browse files Browse the repository at this point in the history
* Updated ADD, SUBTRACT, MULTIPLY, DIVIDE, MODULUS to V2 engine

Signed-off-by: Matthew Wells <[email protected]>
  • Loading branch information
matthewryanwells authored Mar 9, 2023
1 parent 31989f6 commit 9458adc
Show file tree
Hide file tree
Showing 12 changed files with 832 additions and 455 deletions.
56 changes: 38 additions & 18 deletions core/src/main/java/org/opensearch/sql/expression/DSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ public static FunctionExpression abs(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.ABS, expressions);
}

public static FunctionExpression add(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.ADD, expressions);
}

public static FunctionExpression addFunction(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.ADDFUNCTION, expressions);
}

public static FunctionExpression ceil(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.CEIL, expressions);
}
Expand All @@ -166,6 +174,14 @@ public static FunctionExpression crc32(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.CRC32, expressions);
}

public static FunctionExpression divide(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.DIVIDE, expressions);
}

public static FunctionExpression divideFunction(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.DIVIDEFUNCTION, expressions);
}

public static FunctionExpression euler(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.E, expressions);
}
Expand Down Expand Up @@ -202,6 +218,22 @@ public static FunctionExpression mod(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MOD, expressions);
}

public static FunctionExpression modulus(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MODULUS, expressions);
}

public static FunctionExpression modulusFunction(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MODULUSFUNCTION, expressions);
}

public static FunctionExpression multiply(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MULTIPLY, expressions);
}

public static FunctionExpression multiplyFunction(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MULTIPLYFUNCTION, expressions);
}

public static FunctionExpression pi(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.PI, expressions);
}
Expand Down Expand Up @@ -278,20 +310,16 @@ public static FunctionExpression sin(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.SIN, expressions);
}

public static FunctionExpression tan(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.TAN, expressions);
}

public static FunctionExpression add(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.ADD, expressions);
}

public static FunctionExpression subtract(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.SUBTRACT, expressions);
}

public static FunctionExpression multiply(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MULTIPLY, expressions);
public static FunctionExpression subtractFunction(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.SUBTRACTFUNCTION, expressions);
}

public static FunctionExpression tan(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.TAN, expressions);
}

public static FunctionExpression convert_tz(Expression... expressions) {
Expand Down Expand Up @@ -453,14 +481,6 @@ public static FunctionExpression year(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.YEAR, expressions);
}

public static FunctionExpression divide(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.DIVIDE, expressions);
}

public static FunctionExpression module(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MODULES, expressions);
}

public static FunctionExpression substr(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.SUBSTR, expressions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public enum BuiltinFunctionName {
LOG(FunctionName.of("log")),
LOG10(FunctionName.of("log10")),
LOG2(FunctionName.of("log2")),
MOD(FunctionName.of("mod")),
PI(FunctionName.of("pi")),
POW(FunctionName.of("pow")),
POWER(FunctionName.of("power")),
Expand Down Expand Up @@ -131,10 +130,16 @@ public enum BuiltinFunctionName {
* Arithmetic Operators.
*/
ADD(FunctionName.of("+")),
SUBTRACT(FunctionName.of("-")),
MULTIPLY(FunctionName.of("*")),
ADDFUNCTION(FunctionName.of("add")),
DIVIDE(FunctionName.of("/")),
MODULES(FunctionName.of("%")),
DIVIDEFUNCTION(FunctionName.of("divide")),
MOD(FunctionName.of("mod")),
MODULUS(FunctionName.of("%")),
MODULUSFUNCTION(FunctionName.of("modulus")),
MULTIPLY(FunctionName.of("*")),
MULTIPLYFUNCTION(FunctionName.of("multiply")),
SUBTRACT(FunctionName.of("-")),
SUBTRACTFUNCTION(FunctionName.of("subtract")),

/**
* Boolean Operators.
Expand Down
Loading

0 comments on commit 9458adc

Please sign in to comment.