Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Arithmetic functions to V2 engine #1416

Merged
merged 6 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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