diff --git a/core/build.gradle b/core/build.gradle
index 0d303d79d4..5b252a195a 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -33,8 +33,8 @@ repositories {
mavenCentral()
}
-checkstyleTest.ignoreFailures = true
checkstyleMain.ignoreFailures = true
+checkstyleTest.ignoreFailures = true
dependencies {
api group: 'com.google.guava', name: 'guava', version: '32.0.1-jre'
diff --git a/core/src/main/java/org/opensearch/sql/executor/ExecutionEngine.java b/core/src/main/java/org/opensearch/sql/executor/ExecutionEngine.java
index 02c4d4a4b8..43b8ccb62e 100644
--- a/core/src/main/java/org/opensearch/sql/executor/ExecutionEngine.java
+++ b/core/src/main/java/org/opensearch/sql/executor/ExecutionEngine.java
@@ -20,8 +20,8 @@
public interface ExecutionEngine {
/**
- * Execute physical plan and call back response listener. Todo. deprecated this interface after
- * finalize {@link ExecutionContext}.
+ * Execute physical plan and call back response listener.
+ * Todo. deprecated this interface after finalize {@link ExecutionContext}.
*
* @param plan executable physical plan
* @param listener response listener
diff --git a/core/src/main/java/org/opensearch/sql/executor/QueryManager.java b/core/src/main/java/org/opensearch/sql/executor/QueryManager.java
index ed87290065..44d6a1cd84 100644
--- a/core/src/main/java/org/opensearch/sql/executor/QueryManager.java
+++ b/core/src/main/java/org/opensearch/sql/executor/QueryManager.java
@@ -11,8 +11,8 @@
import org.opensearch.sql.executor.execution.AbstractPlan;
/**
- * QueryManager is the high-level interface of core engine. Frontend submit {@link AbstractPlan} to
- * QueryManager.
+ * QueryManager is the high-level interface of core engine. Frontend submit an {@link AbstractPlan}
+ * to QueryManager.
*/
public interface QueryManager {
diff --git a/core/src/main/java/org/opensearch/sql/executor/QueryService.java b/core/src/main/java/org/opensearch/sql/executor/QueryService.java
index e71ad81c25..3e939212bf 100644
--- a/core/src/main/java/org/opensearch/sql/executor/QueryService.java
+++ b/core/src/main/java/org/opensearch/sql/executor/QueryService.java
@@ -29,8 +29,8 @@ public class QueryService {
private final Planner planner;
/**
- * Execute the {@link UnresolvedPlan}, using {@link ResponseListener} to get response. Todo.
- * deprecated this interface after finalize {@link PlanContext}.
+ * Execute the {@link UnresolvedPlan}, using {@link ResponseListener} to get response.
+ * Todo. deprecated this interface after finalize {@link PlanContext}.
*
* @param plan {@link UnresolvedPlan}
* @param listener {@link ResponseListener}
@@ -46,7 +46,8 @@ public void execute(
/**
* Execute the {@link UnresolvedPlan}, with {@link PlanContext} and using {@link ResponseListener}
- * to get response. Todo. Pass split from PlanContext to ExecutionEngine in following PR.
+ * to get response.
+ * Todo. Pass split from PlanContext to ExecutionEngine in following PR.
*
* @param plan {@link LogicalPlan}
* @param planContext {@link PlanContext}
diff --git a/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java b/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java
index 52348319c8..5adb9644e9 100644
--- a/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java
+++ b/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java
@@ -72,8 +72,9 @@ interface ExecutionStrategy {
}
/**
- * execute task with fixed interval. if task run time < interval, trigger next task on next
- * interval. if task run time >= interval, trigger next task immediately.
+ * execute task with fixed interval.
+ * if task run time < interval, trigger next task on next interval.
+ * if task run time >= interval, trigger next task immediately.
*/
@RequiredArgsConstructor
public static class IntervalTriggerExecution implements ExecutionStrategy {
diff --git a/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java b/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java
index c7ae350245..9f14ba1e5d 100644
--- a/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java
+++ b/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java
@@ -41,16 +41,27 @@
import org.opensearch.sql.expression.function.BuiltinFunctionName;
/**
- * Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache. If
+ * Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache.
+ * If
*
*
plan.accept(new CanPaginateVisitor(...))
*
- * returns true, then PaginatedPlanCache.convertToCursor will succeed. Otherwise, it will
- * fail. The purpose of this visitor is to activate legacy engine fallback mechanism. Currently, V2
- * engine does not support queries with: - aggregation (GROUP BY clause or aggregation functions
- * like min/max) - in memory aggregation (window function) - LIMIT/OFFSET clause(s) - without FROM
- * clause - JOIN - a subquery V2 also requires that the table being queried should be an OpenSearch
- * index. See PaginatedPlanCache.canConvertToCursor for usage.
+ * returns true, PaginatedPlanCache.convertToCursor will succeed.
+ * Otherwise, it will fail.
+ * The purpose of this visitor is to activate legacy engine fallback mechanism.
+ * Currently, V2 engine does not support queries with:
+ *
+ *
+ * - aggregation (GROUP BY clause or aggregation functions like min/max)
+ *
- in memory aggregation (window function)
+ *
- LIMIT/OFFSET clause(s)
+ *
- without FROM clause
+ *
- JOIN
+ *
- a subquery
+ *
+ *
+ * V2 also requires that the table being queried should be an OpenSearch index.
+ * See PaginatedPlanCache.canConvertToCursor for usage.
*/
public class CanPaginateVisitor extends AbstractNodeVisitor {
diff --git a/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java b/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java
index 1f11f0805b..17dc7f5cd7 100644
--- a/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java
+++ b/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java
@@ -83,8 +83,12 @@ public T visitNamedAggregator(NamedAggregator node, C context) {
/**
* Call visitFunction() by default rather than visitChildren(). This makes CASE/WHEN able to be
- * handled: 1) by visitFunction() if not overwritten: ex. FilterQueryBuilder 2) by
- * visitCase/When() otherwise if any special logic: ex. ExprReferenceOptimizer
+ * handled:
+ *
+ *
+ * - by visitFunction() if not overwritten: ex. FilterQueryBuilder
+ *
- by visitCase/When() otherwise if any special logic: ex. ExprReferenceOptimizer
+ *
*/
public T visitCase(CaseClause node, C context) {
return visitFunction(node, context);
diff --git a/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java b/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java
index febd468e72..03118311a9 100644
--- a/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java
+++ b/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java
@@ -15,8 +15,9 @@
import org.opensearch.sql.expression.env.Environment;
/**
- * Named expression that represents expression with name. Please see more details in associated
- * unresolved expression operator {@link org.opensearch.sql.ast.expression.Alias}.
+ * Named expression that represents expression with name.
+ * Please see more details in associated unresolved expression operator
+ * {@link org.opensearch.sql.ast.expression.Alias}.
*/
@AllArgsConstructor
@EqualsAndHashCode
diff --git a/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java b/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java
index 67a916a786..cfb87940b4 100644
--- a/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java
+++ b/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java
@@ -61,21 +61,39 @@ public String toString() {
}
/**
- * Resolve the ExprValue from {@link ExprTupleValue} using paths. Considering the following sample
- * data. { "name": "bob smith" "project.year": 1990, "project": { "year": "2020" } "address": {
- * "state": "WA", "city": "seattle", "project.year": 1990 } "address.local": { "state": "WA", } }
- * The paths could be 1. top level, e.g. "name", which will be resolved as "bob smith" 2. multiple
- * paths, e.g. "name.address.state", which will be resolved as "WA" 3. special case, the "." is
- * the path separator, but it is possible that the path include ".", for handling this use case,
- * we define the resolve rule as bellow, e.g. "project.year" is resolved as 1990 instead of 2020.
- * Note. This logic only applied top level none object field. e.g. "address.local.state" been
- * resolved to Missing. but "address.project.year" could been resolved as 1990.
+ *
+ * Resolve the ExprValue from {@link ExprTupleValue} using paths.
+ * Considering the following sample data.
+ * {
+ * "name": "bob smith"
+ * "project.year": 1990,
+ * "project": {
+ * "year": "2020"
+ * }
+ * "address": {
+ * "state": "WA",
+ * "city": "seattle",
+ * "project.year": 1990
+ * }
+ * "address.local": {
+ * "state": "WA",
+ * }
+ * }
+ * The paths could be
+ * 1. top level, e.g. "name", which will be resolved as "bob smith"
+ * 2. multiple paths, e.g. "name.address.state", which will be resolved as "WA"
+ * 3. special case, the "." is the path separator, but it is possible that the path include
+ * ".", for handling this use case, we define the resolve rule as bellow, e.g. "project.year" is
+ * resolved as 1990 instead of 2020. Note. This logic only applied top level none object field.
+ * e.g. "address.local.state" been resolved to Missing. but "address.project.year" could been
+ * resolved as 1990.
*
* Resolve Rule 1. Resolve the full name by combine the paths("x"."y"."z") as whole ("x.y.z").
* 2. Resolve the path recursively through ExprValue.
*
* @param value {@link ExprTupleValue}.
* @return {@link ExprTupleValue}.
+ *
*/
public ExprValue resolve(ExprTupleValue value) {
return resolve(value, paths);
diff --git a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java
index 944bb7b50f..4a1d4d309b 100644
--- a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java
+++ b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java
@@ -34,9 +34,11 @@
import org.opensearch.sql.expression.function.FunctionSignature;
/**
- * The definition of aggregator function avg, Accepts two numbers and produces a number. sum,
- * Accepts two numbers and produces a number. max, Accepts two numbers and produces a number. min,
- * Accepts two numbers and produces a number. count, Accepts two numbers and produces a number.
+ * The definition of aggregator functions avg, sum, min, max and
+ * count.
+ * All of them accept a list of numbers and produce a number. avg, min and
+ * max also accept datetime types.
+ * count accepts values of all types.
*/
@UtilityClass
public class AggregatorFunction {
diff --git a/core/src/main/java/org/opensearch/sql/expression/aggregation/NamedAggregator.java b/core/src/main/java/org/opensearch/sql/expression/aggregation/NamedAggregator.java
index 1c10af5fc7..fa84b74ba5 100644
--- a/core/src/main/java/org/opensearch/sql/expression/aggregation/NamedAggregator.java
+++ b/core/src/main/java/org/opensearch/sql/expression/aggregation/NamedAggregator.java
@@ -12,7 +12,8 @@
/**
* NamedAggregator expression that represents expression with name. Please see more details in
- * associated unresolved expression operator {@link org.opensearch.sql.ast.expression.Alias}.
+ * associated unresolved expression operator
+ * {@link org.opensearch.sql.ast.expression.Alias}.
*/
@EqualsAndHashCode(callSuper = false)
public class NamedAggregator extends Aggregator {
diff --git a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java
index 84c670cb1c..d17d59d358 100644
--- a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java
+++ b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java
@@ -325,12 +325,16 @@ private FunctionResolver current_date() {
}
/**
- * A common signature for `date_add` and `date_sub`. Specify a start date and add/subtract a
- * temporal amount to/from the date. The return type depends on the date type and the interval
- * unit. Detailed supported signatures: (DATE/DATETIME/TIMESTAMP/TIME, INTERVAL) -> DATETIME MySQL
- * has these signatures too (DATE, INTERVAL) -> DATE // when interval has no time part (TIME,
- * INTERVAL) -> TIME // when interval has no date part (STRING, INTERVAL) -> STRING // when
- * argument has date or datetime string, // result has date or datetime depending on interval type
+ * A common signature for `date_add` and `date_sub`.
+ * Specify a start date and add/subtract a temporal amount to/from the date.
+ * The return type depends on the date type and the interval unit. Detailed supported signatures:
+ *
+ * (DATE/DATETIME/TIMESTAMP/TIME, INTERVAL) -> DATETIME
+ * MySQL has these signatures too
+ * (DATE, INTERVAL) -> DATE // when interval has no time part
+ * (TIME, INTERVAL) -> TIME // when interval has no date part
+ * (STRING, INTERVAL) -> STRING // when argument has date or datetime string,
+ * // result has date or datetime depending on interval type
*/
private Stream> get_date_add_date_sub_signatures(
SerializableTriFunction function) {
@@ -344,8 +348,10 @@ private FunctionResolver current_date() {
}
/**
- * A common signature for `adddate` and `subdate`. Adds/subtracts an integer number of days
- * to/from the first argument. (DATE, LONG) -> DATE (TIME/DATETIME/TIMESTAMP, LONG) -> DATETIME
+ * A common signature for `adddate` and `subdate`.
+ * Adds/subtracts an integer number of days to/from the first argument.
+ * (DATE, LONG) -> DATE
+ * (TIME/DATETIME/TIMESTAMP, LONG) -> DATETIME
*/
private Stream> get_adddate_subdate_signatures(
SerializableTriFunction function) {
@@ -367,11 +373,13 @@ private DefaultFunctionResolver adddate() {
}
/**
- * Adds expr2 to expr1 and returns the result. (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME
- * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME TODO: MySQL has these
- * signatures too (STRING, STRING/TIME) -> STRING // second arg - string with time only (x,
- * STRING) -> NULL // second arg - string with timestamp (x, STRING/DATE) -> x // second arg -
- * string with date only
+ * Adds expr2 to expr1 and returns the result.
+ * (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME
+ * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME
+ * TODO: MySQL has these signatures too
+ * (STRING, STRING/TIME) -> STRING // second arg - string with time only
+ * (x, STRING) -> NULL // second arg - string with timestamp
+ * (x, STRING/DATE) -> x // second arg - string with date only
*/
private DefaultFunctionResolver addtime() {
return define(
@@ -444,8 +452,10 @@ private DefaultFunctionResolver addtime() {
}
/**
- * Converts date/time from a specified timezone to another specified timezone. The supported
- * signatures: (DATETIME, STRING, STRING) -> DATETIME (STRING, STRING, STRING) -> DATETIME
+ * Converts date/time from a specified timezone to another specified timezone.
+ * The supported signatures:
+ * (DATETIME, STRING, STRING) -> DATETIME
+ * (STRING, STRING, STRING) -> DATETIME
*/
private DefaultFunctionResolver convert_tz() {
return define(
@@ -555,8 +565,10 @@ private DefaultFunctionResolver datediff() {
}
/**
- * Specify a datetime with time zone field and a time zone to convert to. Returns a local date
- * time. (STRING, STRING) -> DATETIME (STRING) -> DATETIME
+ * Specify a datetime with time zone field and a time zone to convert to.
+ * Returns a local date time.
+ * (STRING, STRING) -> DATETIME
+ * (STRING) -> DATETIME
*/
private FunctionResolver datetime() {
return define(
@@ -798,7 +810,8 @@ private DefaultFunctionResolver period_add() {
/**
* Returns the number of months between periods P1 and P2. P1 and P2 should be in the format YYMM
- * or YYYYMM. (INTEGER, INTEGER) -> INTEGER
+ * or YYYYMM.
+ * (INTEGER, INTEGER) -> INTEGER
*/
private DefaultFunctionResolver period_diff() {
return define(
@@ -847,11 +860,13 @@ private DefaultFunctionResolver subdate() {
}
/**
- * Subtracts expr2 from expr1 and returns the result. (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME
- * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME TODO: MySQL has these
- * signatures too (STRING, STRING/TIME) -> STRING // second arg - string with time only (x,
- * STRING) -> NULL // second arg - string with timestamp (x, STRING/DATE) -> x // second arg -
- * string with date only
+ * Subtracts expr2 from expr1 and returns the result.
+ * (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME
+ * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME
+ * TODO: MySQL has these signatures too
+ * (STRING, STRING/TIME) -> STRING // second arg - string with time only
+ * (x, STRING) -> NULL // second arg - string with timestamp
+ * (x, STRING/DATE) -> x // second arg - string with date only
*/
private DefaultFunctionResolver subtime() {
return define(
@@ -954,11 +969,15 @@ private DefaultFunctionResolver time() {
}
/**
- * Returns different between two times as a time. (TIME, TIME) -> TIME MySQL has these signatures
- * too (DATE, DATE) -> TIME // result is > 24 hours (DATETIME, DATETIME) -> TIME // result is > 24
- * hours (TIMESTAMP, TIMESTAMP) -> TIME // result is > 24 hours (x, x) -> NULL // when args have
- * different types (STRING, STRING) -> TIME // argument strings contain same types only (STRING,
- * STRING) -> NULL // argument strings are different types
+ * Returns different between two times as a time.
+ * (TIME, TIME) -> TIME
+ * MySQL has these signatures too
+ * (DATE, DATE) -> TIME // result is > 24 hours
+ * (DATETIME, DATETIME) -> TIME // result is > 24 hours
+ * (TIMESTAMP, TIMESTAMP) -> TIME // result is > 24 hours
+ * (x, x) -> NULL // when args have different types
+ * (STRING, STRING) -> TIME // argument strings contain same types only
+ * (STRING, STRING) -> NULL // argument strings are different types
*/
private DefaultFunctionResolver timediff() {
return define(
@@ -979,11 +998,13 @@ private DefaultFunctionResolver time_to_sec() {
}
/**
- * Extracts the timestamp of a date and time value. Input strings may contain a timestamp only in
- * format 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]' STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP
- * STRING/DATE/TIME/DATETIME/TIMESTAMP, STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP All types
- * are converted to TIMESTAMP actually before the function call - it is responsibility of the
- * automatic cast mechanism defined in `ExprCoreType` and performed by `TypeCastOperator`.
+ * Extracts the timestamp of a date and time value.
+ * Input strings may contain a timestamp only in format 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'
+ * STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP
+ * STRING/DATE/TIME/DATETIME/TIMESTAMP, STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP
+ * All types are converted to TIMESTAMP actually before the function call - it is responsibility
+ *
+ * of the automatic cast mechanism defined in `ExprCoreType` and performed by `TypeCastOperator`.
*/
private DefaultFunctionResolver timestamp() {
return define(
@@ -1221,9 +1242,13 @@ private DefaultFunctionResolver yearweek() {
}
/**
- * Formats date according to format specifier. First argument is date, second is format. Detailed
- * supported signatures: (STRING, STRING) -> STRING (DATE, STRING) -> STRING (DATETIME, STRING) ->
- * STRING (TIME, STRING) -> STRING (TIMESTAMP, STRING) -> STRING
+ * Formats date according to format specifier. First argument is date, second is format.
+ * Detailed supported signatures:
+ * (STRING, STRING) -> STRING
+ * (DATE, STRING) -> STRING
+ * (DATETIME, STRING) -> STRING
+ * (TIME, STRING) -> STRING
+ * (TIMESTAMP, STRING) -> STRING
*/
private DefaultFunctionResolver date_format() {
return define(
@@ -1302,9 +1327,13 @@ private ExprValue exprDateApplyInterval(
}
/**
- * Formats date according to format specifier. First argument is time, second is format. Detailed
- * supported signatures: (STRING, STRING) -> STRING (DATE, STRING) -> STRING (DATETIME, STRING) ->
- * STRING (TIME, STRING) -> STRING (TIMESTAMP, STRING) -> STRING
+ * Formats date according to format specifier. First argument is time, second is format.
+ * Detailed supported signatures:
+ * (STRING, STRING) -> STRING
+ * (DATE, STRING) -> STRING
+ * (DATETIME, STRING) -> STRING
+ * (TIME, STRING) -> STRING
+ * (TIMESTAMP, STRING) -> STRING
*/
private DefaultFunctionResolver time_format() {
return define(
@@ -1683,10 +1712,15 @@ private ExprValue exprLastDayToday(Clock clock) {
}
/**
- * Following MySQL, function receives arguments of type double and rounds them before use.
- * Furthermore: - zero year interpreted as 2000 - negative year is not accepted - @dayOfYear
- * should be greater than 1 - if @dayOfYear is greater than 365/366, calculation goes to the next
- * year(s)
+ * Following MySQL, function receives arguments of type double and rounds them before use.
+ * Furthermore:
+ *
+ *
+ * - zero year interpreted as 2000
+ *
- negative year is not accepted
+ *
- @dayOfYear should be greater than 1
+ *
- if @dayOfYear is greater than 365/366, calculation goes to the next year(s)
+ *
*
* @param yearExpr year
* @param dayOfYearExp day of the @year, starting from 1
diff --git a/core/src/main/java/org/opensearch/sql/expression/function/FunctionSignature.java b/core/src/main/java/org/opensearch/sql/expression/function/FunctionSignature.java
index 665486afdc..e1246cde28 100644
--- a/core/src/main/java/org/opensearch/sql/expression/function/FunctionSignature.java
+++ b/core/src/main/java/org/opensearch/sql/expression/function/FunctionSignature.java
@@ -29,8 +29,10 @@ public class FunctionSignature {
/**
* calculate the function signature match degree.
*
- * @return EXACTLY_MATCH: exactly match NOT_MATCH: not match By widening rule, the small number
- * means better match
+ * @return
+ * EXACTLY_MATCH: exactly match
+ * NOT_MATCH: not match
+ * By widening rule, the small number means better match
*/
public int match(FunctionSignature functionSignature) {
List functionTypeList = functionSignature.getParamTypeList();
diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java
index 3969b5310e..82b91e1d34 100644
--- a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java
+++ b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java
@@ -29,10 +29,12 @@
import org.opensearch.sql.expression.function.FunctionName;
/**
- * The definition of arithmetic function add, Accepts two numbers and produces a number. subtract,
- * Accepts two numbers and produces a number. multiply, Accepts two numbers and produces a number.
- * divide, Accepts two numbers and produces a number. module, Accepts two numbers and produces a
- * number.
+ * The definition of arithmetic function
+ * add, Accepts two numbers and produces a number.
+ * subtract, Accepts two numbers and produces a number.
+ * multiply, Accepts two numbers and produces a number.
+ * divide, Accepts two numbers and produces a number.
+ * module, Accepts two numbers and produces a number.
*/
@UtilityClass
public class ArithmeticFunction {
@@ -56,9 +58,11 @@ public static void register(BuiltinFunctionRepository repository) {
}
/**
- * Definition of add(x, y) function. Returns the number x plus number y The supported signature of
- * add function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:
- * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE) -> wider type between types of x and y
+ * Definition of add(x, y) function.
+ * Returns the number x plus number y
+ * The supported signature of add function is
+ * (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
+ * -> wider type between types of x and y
*/
private static DefaultFunctionResolver addBase(FunctionName functionName) {
return define(
@@ -108,9 +112,11 @@ private static DefaultFunctionResolver addFunction() {
}
/**
- * Definition of divide(x, y) function. Returns the number x divided by number y The supported
- * signature of divide function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:
- * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE) -> wider type between types of x and y
+ * Definition of divide(x, y) function.
+ * Returns the number x divided by number y
+ * The supported signature of divide function is
+ * (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
+ * -> wider type between types of x and y
*/
private static DefaultFunctionResolver divideBase(FunctionName functionName) {
return define(
@@ -180,9 +186,11 @@ private static DefaultFunctionResolver divideFunction() {
}
/**
- * Definition of modulus(x, y) function. Returns the number x modulo by number y The supported
- * signature of modulo function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:
- * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE) -> wider type between types of x and y
+ * Definition of modulus(x, y) function.
+ * Returns the number x modulo by number y
+ * The supported signature of modulo function is
+ * (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
+ * -> wider type between types of x and y
*/
private static DefaultFunctionResolver modulusBase(FunctionName functionName) {
return define(
@@ -256,9 +264,11 @@ private static DefaultFunctionResolver modulusFunction() {
}
/**
- * Definition of multiply(x, y) function. Returns the number x multiplied by number y The
- * supported signature of multiply function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:
- * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE) -> wider type between types of x and y
+ * Definition of multiply(x, y) function.
+ * Returns the number x multiplied by number y
+ * The supported signature of multiply function is
+ * (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
+ * > -> wider type between types of x and y
*/
private static DefaultFunctionResolver multiplyBase(FunctionName functionName) {
return define(
@@ -308,9 +318,11 @@ private static DefaultFunctionResolver multiplyFunction() {
}
/**
- * Definition of subtract(x, y) function. Returns the number x minus number y The supported
- * signature of subtract function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:
- * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE) -> wider type between types of x and y
+ * Definition of subtract(x, y) function.
+ * Returns the number x minus number y
+ * The supported signature of subtract function is
+ * (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
+ * -> wider type between types of x and y
*/
private static DefaultFunctionResolver subtractBase(FunctionName functionName) {
return define(
diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java
index 21a348504e..0ba434c26d 100644
--- a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java
+++ b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java
@@ -112,8 +112,9 @@ private static DefaultFunctionResolver baseMathFunction(
}
/**
- * Definition of abs() function. The supported signature of abs() function are INT -> INT LONG ->
- * LONG FLOAT -> FLOAT DOUBLE -> DOUBLE
+ * Definition of abs() function.<\b>
+ * The supported signature of abs() function are
+ * INT/LONG/FLOAT/DOUBLE -> INT/LONG/FLOAT/DOUBLE
*/
private static DefaultFunctionResolver abs() {
return define(
@@ -133,8 +134,9 @@ private static DefaultFunctionResolver abs() {
}
/**
- * Definition of ceil(x)/ceiling(x) function. Calculate the next highest integer that x rounds up
- * to The supported signature of ceil/ceiling function is DOUBLE -> INTEGER
+ * Definition of ceil(x)/ceiling(x) function.<\b>
+ * Calculate the next highest integer that x rounds up to The supported signature of ceil/ceiling
+ * function is DOUBLE -> INTEGER
*/
private static DefaultFunctionResolver ceil() {
return define(
@@ -151,9 +153,11 @@ private static DefaultFunctionResolver ceiling() {
}
/**
- * Definition of conv(x, a, b) function. Convert number x from base a to base b The supported
- * signature of floor function is (STRING, INTEGER, INTEGER) -> STRING (INTEGER, INTEGER, INTEGER)
- * -> STRING
+ * Definition of conv(x, a, b) function.<\b>
+ * Convert number x from base a to base b
+ * The supported signature of floor function is
+ * (STRING, INTEGER, INTEGER) -> STRING
+ * (INTEGER, INTEGER, INTEGER) -> STRING
*/
private static DefaultFunctionResolver conv() {
return define(
@@ -183,8 +187,10 @@ private static DefaultFunctionResolver conv() {
}
/**
- * Definition of crc32(x) function. Calculate a cyclic redundancy check value and returns a 32-bit
- * unsigned value The supported signature of crc32 function is STRING -> LONG
+ * Definition of crc32(x) function.<\b>
+ * Calculate a cyclic redundancy check value and returns a 32-bit unsigned value
+ * The supported signature of crc32 function is
+ * STRING -> LONG
*/
private static DefaultFunctionResolver crc32() {
return define(
@@ -200,14 +206,18 @@ private static DefaultFunctionResolver crc32() {
STRING));
}
- /** Definition of e() function. Get the Euler's number. () -> DOUBLE */
+ /**
+ * Definition of e() function.
+ * Get the Euler's number. () -> DOUBLE
+ */
private static DefaultFunctionResolver euler() {
return define(BuiltinFunctionName.E.getName(), impl(() -> new ExprDoubleValue(Math.E), DOUBLE));
}
/**
- * Definition of exp(x) function. Calculate exponent function e to the x The supported signature
- * of exp function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of exp(x) function.
+ * Calculate exponent function e to the x The supported signature of exp function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver exp() {
return baseMathFunction(
@@ -217,8 +227,9 @@ private static DefaultFunctionResolver exp() {
}
/**
- * Definition of expm1(x) function. Calculate exponent function e to the x, minus 1 The supported
- * signature of exp function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of expm1(x) function.
+ * Calculate exponent function e to the x, minus 1 The supported signature of exp function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver expm1() {
return baseMathFunction(
@@ -228,8 +239,9 @@ private static DefaultFunctionResolver expm1() {
}
/**
- * Definition of floor(x) function. Calculate the next nearest whole integer that x rounds down to
- * The supported signature of floor function is DOUBLE -> INTEGER
+ * Definition of floor(x) function.
+ * Calculate the next nearest whole integer that x rounds down to The supported signature of floor
+ * function is DOUBLE -> INTEGER
*/
private static DefaultFunctionResolver floor() {
return define(
@@ -255,9 +267,9 @@ private static DefaultFunctionResolver ln() {
}
/**
- * Definition of log(b, x) function. Calculate the logarithm of x using b as the base The
- * supported signature of log function is (b: INTEGER/LONG/FLOAT/DOUBLE, x:
- * INTEGER/LONG/FLOAT/DOUBLE]) -> DOUBLE
+ * Definition of log(b, x) function.
+ * Calculate the logarithm of x using b as the base The supported signature of log function is
+ * (b: INTEGER/LONG/FLOAT/DOUBLE, x: INTEGER/LONG/FLOAT/DOUBLE]) -> DOUBLE
*/
private static DefaultFunctionResolver log() {
ImmutableList.Builder<
@@ -297,7 +309,8 @@ private static DefaultFunctionResolver log() {
}
/**
- * Definition of log10(x) function. Calculate base-10 logarithm of x The supported signature of
+ * Definition of log10(x) function.
+ * Calculate base-10 logarithm of x The supported signature of
* log function is SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver log10() {
@@ -311,7 +324,8 @@ private static DefaultFunctionResolver log10() {
}
/**
- * Definition of log2(x) function. Calculate base-2 logarithm of x The supported signature of log
+ * Definition of log2(x) function.
+ * Calculate base-2 logarithm of x The supported signature of log
* function is SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver log2() {
@@ -325,9 +339,11 @@ private static DefaultFunctionResolver log2() {
}
/**
- * Definition of mod(x, y) function. Calculate the remainder of x divided by y The supported
- * signature of mod function is (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) ->
- * wider type between types of x and y
+ * Definition of mod(x, y) function.
+ * Calculate the remainder of x divided by y
+ * The supported signature of mod function is
+ * (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE)
+ * -> wider type between types of x and y
*/
private static DefaultFunctionResolver mod() {
return define(
@@ -389,16 +405,25 @@ private static DefaultFunctionResolver mod() {
DOUBLE));
}
- /** Definition of pi() function. Get the value of pi. () -> DOUBLE */
+ /**
+ * Definition of pi() function.
+ * Get the value of pi.
+ * () -> DOUBLE
+ */
private static DefaultFunctionResolver pi() {
return define(
BuiltinFunctionName.PI.getName(), impl(() -> new ExprDoubleValue(Math.PI), DOUBLE));
}
/**
- * Definition of pow(x, y)/power(x, y) function. Calculate the value of x raised to the power of y
- * The supported signature of pow/power function is (INTEGER, INTEGER) -> DOUBLE (LONG, LONG) ->
- * DOUBLE (FLOAT, FLOAT) -> DOUBLE (DOUBLE, DOUBLE) -> DOUBLE
+
+ * Definition of pow(x, y)/power(x, y) function.
+ * Calculate the value of x raised to the power of y
+ * The supported signature of pow/power function is
+ * (INTEGER, INTEGER) -> DOUBLE
+ * (LONG, LONG) -> DOUBLE
+ * (FLOAT, FLOAT) -> DOUBLE
+ * (DOUBLE, DOUBLE) -> DOUBLE
*/
private static DefaultFunctionResolver pow() {
return define(BuiltinFunctionName.POW.getName(), powerFunctionImpl());
@@ -450,10 +475,13 @@ private static DefaultFunctionResolver power() {
}
/**
- * Definition of rand() and rand(N) function. rand() returns a random floating-point value in the
- * range 0 <= value < 1.0 If integer N is specified, the seed is initialized prior to execution.
+ * Definition of rand() and rand(N) function.
+ * rand() returns a random floating-point value in the range 0 <= value < 1.0
+ * If integer N is specified, the seed is initialized prior to execution.
* One implication of this behavior is with identical argument N,rand(N) returns the same value
+ *
* each time, and thus produces a repeatable sequence of column values. The supported signature of
+ *
* rand function is ([INTEGER]) -> FLOAT
*/
private static DefaultFunctionResolver rand() {
@@ -467,8 +495,10 @@ private static DefaultFunctionResolver rand() {
}
/**
- * Definition of rint(x) function. Returns the closest whole integer value to x The supported
- * signature is BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of rint(x) function.
+ * Returns the closest whole integer value to x
+ * The supported signature is
+ * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver rint() {
return baseMathFunction(
@@ -478,10 +508,13 @@ private static DefaultFunctionResolver rint() {
}
/**
- * Definition of round(x)/round(x, d) function. Rounds the argument x to d decimal places, d
- * defaults to 0 if not specified. The supported signature of round function is (x: INTEGER [, y:
- * INTEGER]) -> INTEGER (x: LONG [, y: INTEGER]) -> LONG (x: FLOAT [, y: INTEGER]) -> FLOAT (x:
- * DOUBLE [, y: INTEGER]) -> DOUBLE
+ * Definition of round(x)/round(x, d) function.
+ * Rounds the argument x to d decimal places, d defaults to 0 if not specified.
+ * The supported signature of round function is
+ * (x: INTEGER [, y: INTEGER]) -> INTEGER
+ * (x: LONG [, y: INTEGER]) -> LONG
+ * (x: FLOAT [, y: INTEGER]) -> FLOAT
+ * (x: DOUBLE [, y: INTEGER]) -> DOUBLE
*/
private static DefaultFunctionResolver round() {
return define(
@@ -553,8 +586,10 @@ private static DefaultFunctionResolver round() {
}
/**
- * Definition of sign(x) function. Returns the sign of the argument as -1, 0, or 1 depending on
- * whether x is negative, zero, or positive The supported signature is
+ * Definition of sign(x) function.
+ * Returns the sign of the argument as -1, 0, or 1
+ * depending on whether x is negative, zero, or positive
+ * The supported signature is
* SHORT/INTEGER/LONG/FLOAT/DOUBLE -> INTEGER
*/
private static DefaultFunctionResolver sign() {
@@ -565,8 +600,10 @@ private static DefaultFunctionResolver sign() {
}
/**
- * Definition of signum(x) function. Returns the sign of the argument as -1.0, 0, or 1.0 depending
- * on whether x is negative, zero, or positive The supported signature is
+ * Definition of signum(x) function.
+ * Returns the sign of the argument as -1.0, 0, or 1.0
+ * depending on whether x is negative, zero, or positive
+ * The supported signature is
* BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE -> INTEGER
*/
private static DefaultFunctionResolver signum() {
@@ -577,8 +614,10 @@ private static DefaultFunctionResolver signum() {
}
/**
- * Definition of sinh(x) function. Returns the hyperbolix sine of x, defined as (((e^x) -
- * (e^(-x))) / 2) The supported signature is BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of sinh(x) function.
+ * Returns the hyperbolix sine of x, defined as (((e^x) - (e^(-x))) / 2)
+ * The supported signature is
+ * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver sinh() {
return baseMathFunction(
@@ -588,8 +627,10 @@ private static DefaultFunctionResolver sinh() {
}
/**
- * Definition of sqrt(x) function. Calculate the square root of a non-negative number x The
- * supported signature is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of sqrt(x) function.
+ * Calculate the square root of a non-negative number x
+ * The supported signature is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver sqrt() {
return baseMathFunction(
@@ -602,8 +643,10 @@ private static DefaultFunctionResolver sqrt() {
}
/**
- * Definition of cbrt(x) function. Calculate the cube root of a number x The supported signature
- * is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of cbrt(x) function.
+ * Calculate the cube root of a number x
+ * The supported signature is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver cbrt() {
return baseMathFunction(
@@ -613,9 +656,13 @@ private static DefaultFunctionResolver cbrt() {
}
/**
- * Definition of truncate(x, d) function. Returns the number x, truncated to d decimal places The
- * supported signature of round function is (x: INTEGER, y: INTEGER) -> LONG (x: LONG, y: INTEGER)
- * -> LONG (x: FLOAT, y: INTEGER) -> DOUBLE (x: DOUBLE, y: INTEGER) -> DOUBLE
+ * Definition of truncate(x, d) function.
+ * Returns the number x, truncated to d decimal places
+ * The supported signature of round function is
+ * (x: INTEGER, y: INTEGER) -> LONG
+ * (x: LONG, y: INTEGER) -> LONG
+ * (x: FLOAT, y: INTEGER) -> DOUBLE
+ * (x: DOUBLE, y: INTEGER) -> DOUBLE
*/
private static DefaultFunctionResolver truncate() {
return define(
@@ -663,9 +710,11 @@ private static DefaultFunctionResolver truncate() {
}
/**
- * Definition of acos(x) function. Calculates the arc cosine of x, that is, the value whose cosine
- * is x. Returns NULL if x is not in the range -1 to 1. The supported signature of acos function
- * is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of acos(x) function.
+ * Calculates the arc cosine of x, that is, the value whose cosine is x.
+ * Returns NULL if x is not in the range -1 to 1.
+ * The supported signature of acos function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver acos() {
return define(
@@ -685,9 +734,11 @@ private static DefaultFunctionResolver acos() {
}
/**
- * Definition of asin(x) function. Calculates the arc sine of x, that is, the value whose sine is
- * x. Returns NULL if x is not in the range -1 to 1. The supported signature of asin function is
- * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of asin(x) function.
+ * Calculates the arc sine of x, that is, the value whose sine is x.
+ * Returns NULL if x is not in the range -1 to 1.
+ * The supported signature of asin function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver asin() {
return define(
@@ -707,11 +758,12 @@ private static DefaultFunctionResolver asin() {
}
/**
- * Definition of atan(x) and atan(y, x) function. atan(x) calculates the arc tangent of x, that
- * is, the value whose tangent is x. atan(y, x) calculates the arc tangent of y / x, except that
- * the signs of both arguments are used to determine the quadrant of the result. The supported
- * signature of atan function is (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) ->
- * DOUBLE
+ * Definition of atan(x) and atan(y, x) function.
+ * atan(x) calculates the arc tangent of x, that is, the value whose tangent is x.
+ * atan(y, x) calculates the arc tangent of y / x, except that the signs of both arguments
+ * are used to determine the quadrant of the result.
+ * The supported signature of atan function is
+ * (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) -> DOUBLE
*/
private static DefaultFunctionResolver atan() {
ImmutableList.Builder<
@@ -737,9 +789,11 @@ private static DefaultFunctionResolver atan() {
}
/**
- * Definition of atan2(y, x) function. Calculates the arc tangent of y / x, except that the signs
- * of both arguments are used to determine the quadrant of the result. The supported signature of
- * atan2 function is (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) -> DOUBLE
+ * Definition of atan2(y, x) function.
+ * Calculates the arc tangent of y / x, except that the signs of both arguments are used to
+ * determine the quadrant of the result.
+ * The supported signature of atan2 function is
+ * (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) -> DOUBLE
*/
private static DefaultFunctionResolver atan2() {
ImmutableList.Builder<
@@ -760,8 +814,10 @@ private static DefaultFunctionResolver atan2() {
}
/**
- * Definition of cos(x) function. Calculates the cosine of X, where X is given in radians The
- * supported signature of cos function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of cos(x) function.
+ * Calculates the cosine of X, where X is given in radians
+ * The supported signature of cos function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver cos() {
return baseMathFunction(
@@ -771,8 +827,10 @@ private static DefaultFunctionResolver cos() {
}
/**
- * Definition of cosh(x) function. Returns the hyperbolic cosine of x, defined as (((e^x) +
- * (e^(-x))) / 2) The supported signature is BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of cosh(x) function.
+ * Returns the hyperbolic cosine of x, defined as (((e^x) + (e^(-x))) / 2)
+ * The supported signature is
+ * BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver cosh() {
return baseMathFunction(
@@ -782,8 +840,9 @@ private static DefaultFunctionResolver cosh() {
}
/**
- * Definition of cot(x) function. Calculates the cotangent of x The supported signature of cot
- * function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of cot(x) function.<\b>
+ * Calculates the cotangent of x The supported signature of cot function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver cot() {
return define(
@@ -807,8 +866,9 @@ private static DefaultFunctionResolver cot() {
}
/**
- * Definition of degrees(x) function. Converts x from radians to degrees The supported signature
- * of degrees function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of degrees(x) function.
+ * Converts x from radians to degrees The supported signature of degrees function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver degrees() {
return baseMathFunction(
@@ -818,8 +878,9 @@ private static DefaultFunctionResolver degrees() {
}
/**
- * Definition of radians(x) function. Converts x from degrees to radians The supported signature
- * of radians function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of radians(x) function.
+ * Converts x from degrees to radians The supported signature of radians function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver radians() {
return baseMathFunction(
@@ -829,8 +890,10 @@ private static DefaultFunctionResolver radians() {
}
/**
- * Definition of sin(x) function. Calculates the sine of x, where x is given in radians The
- * supported signature of sin function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of sin(x) function.
+ * Calculates the sine of x, where x is given in radians The supported signature of sin function
+ * is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver sin() {
return baseMathFunction(
@@ -840,8 +903,10 @@ private static DefaultFunctionResolver sin() {
}
/**
- * Definition of tan(x) function. Calculates the tangent of x, where x is given in radians The
- * supported signature of tan function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
+ * Definition of tan(x) function.
+ * Calculates the tangent of x, where x is given in radians The supported signature of tan
+ * function is
+ * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static DefaultFunctionResolver tan() {
return baseMathFunction(
diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java
index 042a4f3ad4..bf6b3c22f5 100644
--- a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java
+++ b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java
@@ -29,10 +29,11 @@
import org.opensearch.sql.utils.OperatorUtils;
/**
- * The definition of binary predicate function and, Accepts two Boolean values and produces a
- * Boolean. or, Accepts two Boolean values and produces a Boolean. xor, Accepts two Boolean values
- * and produces a Boolean. equalTo, Compare the left expression and right expression and produces a
- * Boolean.
+ * The definition of binary predicate function
+ * and, Accepts two Boolean values and produces a Boolean.
+ * or, Accepts two Boolean values and produces a Boolean.
+ * xor, Accepts two Boolean values and produces a Boolean.
+ * equalTo, Compare the left expression and right expression and produces a Boolean.
*/
@UtilityClass
public class BinaryPredicateOperator {
@@ -57,9 +58,65 @@ public static void register(BuiltinFunctionRepository repository) {
}
/**
- * The and logic. A B A AND B TRUE TRUE TRUE TRUE FALSE FALSE TRUE NULL NULL TRUE MISSING MISSING
- * FALSE FALSE FALSE FALSE NULL FALSE FALSE MISSING FALSE NULL NULL NULL NULL MISSING MISSING
- * MISSING MISSING MISSING
+ * The and logic.
+ *
+ *
+ *
+ * A |
+ * B |
+ * A AND B |
+ *
+ *
+ * TRUE |
+ * TRUE |
+ * TRUE |
+ *
+ *
+ * TRUE |
+ * FALSE |
+ * FALSE |
+ *
+ *
+ * TRUE |
+ * NULL |
+ * NULL |
+ *
+ *
+ * TRUE |
+ * MISSING |
+ * MISSING |
+ *
+ *
+ * FALSE |
+ * FALSE |
+ * FALSE |
+ *
+ *
+ * FALSE |
+ * NULL |
+ * FALSE |
+ *
+ *
+ * FALSE |
+ * MISSING |
+ * FALSE |
+ *
+ *
+ * NULL |
+ * NULL |
+ * NULL |
+ *
+ *
+ * NULL |
+ * MISSING |
+ * MISSING |
+ *
+ *
+ * MISSING |
+ * MISSING |
+ * MISSING |
+ *
+ *
*/
private static Table andTable =
new ImmutableTable.Builder()
@@ -76,9 +133,65 @@ public static void register(BuiltinFunctionRepository repository) {
.build();
/**
- * The or logic. A B A AND B TRUE TRUE TRUE TRUE FALSE TRUE TRUE NULL TRUE TRUE MISSING TRUE FALSE
- * FALSE FALSE FALSE NULL NULL FALSE MISSING MISSING NULL NULL NULL NULL MISSING NULL MISSING
- * MISSING MISSING
+ * The or logic.
+ *
+ *
+ *
+ * A |
+ * B |
+ * A OR B |
+ *
+ *
+ * TRUE |
+ * TRUE |
+ * TRUE |
+ *
+ *
+ * TRUE |
+ * FALSE |
+ * TRUE |
+ *
+ *
+ * TRUE |
+ * NULL |
+ * TRUE |
+ *
+ *
+ * TRUE |
+ * MISSING |
+ * TRUE |
+ *
+ *
+ * FALSE |
+ * FALSE |
+ * FALSE |
+ *
+ *
+ * FALSE |
+ * NULL |
+ * NULL |
+ *
+ *
+ * FALSE |
+ * MISSING |
+ * MISSING |
+ *
+ *
+ * NULL |
+ * NULL |
+ * NULL |
+ *
+ *
+ * NULL |
+ * MISSING |
+ * NULL |
+ *
+ *
+ * MISSING |
+ * MISSING |
+ * MISSING |
+ *
+ *
*/
private static Table orTable =
new ImmutableTable.Builder()
@@ -95,9 +208,65 @@ public static void register(BuiltinFunctionRepository repository) {
.build();
/**
- * The xor logic. A B A AND B TRUE TRUE FALSE TRUE FALSE TRUE TRUE NULL TRUE TRUE MISSING TRUE
- * FALSE FALSE FALSE FALSE NULL NULL FALSE MISSING MISSING NULL NULL NULL NULL MISSING NULL
- * MISSING MISSING MISSING
+ * The xor logic.
+ *
+ *
+ *
+ * A |
+ * B |
+ * A XOR B |
+ *
+ *
+ * TRUE |
+ * TRUE |
+ * FALSE |
+ *
+ *
+ * TRUE |
+ * FALSE |
+ * TRUE |
+ *
+ *
+ * TRUE |
+ * NULL |
+ * TRUE |
+ *
+ *
+ * TRUE |
+ * MISSING |
+ * TRUE |
+ *
+ *
+ * FALSE |
+ * FALSE |
+ * FALSE |
+ *
+ *
+ * FALSE |
+ * NULL |
+ * NULL |
+ *
+ *
+ * FALSE |
+ * MISSING |
+ * MISSING |
+ *
+ *
+ * NULL |
+ * NULL |
+ * NULL |
+ *
+ *
+ * NULL |
+ * MISSING |
+ * NULL |
+ *
+ *
+ * MISSING |
+ * MISSING |
+ * MISSING |
+ *
+ *
*/
private static Table xorTable =
new ImmutableTable.Builder()
diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java
index dbea762ae1..ad9d9ac934 100644
--- a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java
+++ b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java
@@ -48,7 +48,32 @@ private static DefaultFunctionResolver not() {
FunctionDSL.impl(UnaryPredicateOperator::not, BOOLEAN, BOOLEAN));
}
- /** The not logic. A NOT A TRUE FALSE FALSE TRUE NULL NULL MISSING MISSING */
+ /**
+ * The not logic.
+ *
+ *
+ *
+ * A |
+ * NOT A |
+ *
+ *
+ * TRUE |
+ * FALSE |
+ *
+ *
+ * FALSE |
+ * TRUE |
+ *
+ *
+ * NULL |
+ * NULL |
+ *
+ *
+ * MISSING |
+ * MISSING |
+ *
+ *
+ */
public ExprValue not(ExprValue v) {
if (v.isMissing() || v.isNull()) {
return v;
diff --git a/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java b/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java
index a4db50944c..949ed52e7f 100644
--- a/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java
+++ b/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java
@@ -39,9 +39,40 @@ public ExprValue valueOf(Environment valueEnv) {
}
/**
- * Return type follows the following table. FIELD VALUE RETURN_TYPE int/long integer int/long
- * (field type) int/long double double float/double integer float/double (field type) float/double
- * double float/double (field type) other any field type
+ * Return type follows the following table.
+ *
+ *
+ *
+ * FIELD |
+ * VALUE |
+ * RETURN_TYPE |
+ *
+ *
+ * int/long |
+ * integer |
+ * int/long (field type) |
+ *
+ *
+ * int/long |
+ * double |
+ * double |
+ *
+ *
+ * float/double |
+ * integer |
+ * float/double (field type) |
+ *
+ *
+ * float/double |
+ * double |
+ * float/double (field type) |
+ *
+ *
+ * other |
+ * any |
+ * field type |
+ *
+ *
*/
@Override
public ExprType type() {
diff --git a/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java b/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java
index 1ba5854596..1cf7f64867 100644
--- a/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java
+++ b/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java
@@ -68,8 +68,9 @@ public void register(BuiltinFunctionRepository repository) {
}
/**
- * Gets substring starting at given point, for optional given length. Form of this function using
- * keywords instead of comma delimited variables is not supported. Supports following signatures:
+ * Gets substring starting at given point, for optional given length.
+ * Form of this function using keywords instead of comma delimited variables is not supported.
+ * Supports following signatures:
* (STRING, INTEGER)/(STRING, INTEGER, INTEGER) -> STRING
*/
private DefaultFunctionResolver substringSubstr(FunctionName functionName) {
@@ -92,7 +93,11 @@ private DefaultFunctionResolver substr() {
return substringSubstr(BuiltinFunctionName.SUBSTR.getName());
}
- /** Removes leading whitespace from string. Supports following signatures: STRING -> STRING */
+ /**
+ * Removes leading whitespace from string.
+ * Supports following signatures:
+ * STRING -> STRING
+ */
private DefaultFunctionResolver ltrim() {
return define(
BuiltinFunctionName.LTRIM.getName(),
@@ -102,7 +107,11 @@ private DefaultFunctionResolver ltrim() {
STRING));
}
- /** Removes trailing whitespace from string. Supports following signatures: STRING -> STRING */
+ /**
+ * Removes trailing whitespace from string.
+ * Supports following signatures:
+ * STRING -> STRING
+ */
private DefaultFunctionResolver rtrim() {
return define(
BuiltinFunctionName.RTRIM.getName(),
@@ -113,9 +122,11 @@ private DefaultFunctionResolver rtrim() {
}
/**
- * Removes leading and trailing whitespace from string. Has option to specify a String to trim
- * instead of whitespace but this is not yet supported. Supporting String specification requires
- * finding keywords inside TRIM command. Supports following signatures: STRING -> STRING
+ * Removes leading and trailing whitespace from string.
+ * Has option to specify a String to trim instead of whitespace but this is not yet supported.
+ * Supporting String specification requires finding keywords inside TRIM command.
+ * Supports following signatures:
+ * STRING -> STRING
*/
private DefaultFunctionResolver trim() {
return define(
@@ -126,7 +137,11 @@ private DefaultFunctionResolver trim() {
STRING));
}
- /** Converts String to lowercase. Supports following signatures: STRING -> STRING */
+ /**
+ * Converts String to lowercase.
+ * Supports following signatures:
+ * STRING -> STRING
+ */
private DefaultFunctionResolver lower() {
return define(
BuiltinFunctionName.LOWER.getName(),
@@ -136,7 +151,11 @@ private DefaultFunctionResolver lower() {
STRING));
}
- /** Converts String to uppercase. Supports following signatures: STRING -> STRING */
+ /**
+ * Converts String to uppercase.
+ * Supports following signatures:
+ * STRING -> STRING
+ */
private DefaultFunctionResolver upper() {
return define(
BuiltinFunctionName.UPPER.getName(),
@@ -147,8 +166,9 @@ private DefaultFunctionResolver upper() {
}
/**
- * Concatenates a list of Strings. Supports following signatures: (STRING, STRING, ...., STRING)
- * -> STRING
+ * Concatenates a list of Strings.
+ * Supports following signatures:
+ * (STRING, STRING, ...., STRING) -> STRING
*/
private DefaultFunctionResolver concat() {
FunctionName concatFuncName = BuiltinFunctionName.CONCAT.getName();
@@ -185,9 +205,12 @@ public ExprType type() {
}
/**
- * TODO: https://github.com/opendistro-for-elasticsearch/sql/issues/710 Extend to accept variable
- * argument amounts. Concatenates a list of Strings with a separator string. Supports following
- * signatures: (STRING, STRING, STRING) -> STRING
+ * TODO: https://github.com/opendistro-for-elasticsearch/sql/issues/710
+ * Extend to accept variable argument amounts.
+ *
+ * Concatenates a list of Strings with a separator string. Supports following
+ * signatures:
+ * (STRING, STRING, STRING) -> STRING
*/
private DefaultFunctionResolver concat_ws() {
return define(
@@ -203,7 +226,11 @@ private DefaultFunctionResolver concat_ws() {
STRING));
}
- /** Calculates length of String in bytes. Supports following signatures: STRING -> INTEGER */
+ /**
+ * Calculates length of String in bytes.
+ * Supports following signatures:
+ * STRING -> INTEGER
+ */
private DefaultFunctionResolver length() {
return define(
BuiltinFunctionName.LENGTH.getName(),
@@ -214,7 +241,8 @@ private DefaultFunctionResolver length() {
}
/**
- * Does String comparison of two Strings and returns Integer value. Supports following signatures:
+ * Does String comparison of two Strings and returns Integer value.
+ * Supports following signatures:
* (STRING, STRING) -> INTEGER
*/
private DefaultFunctionResolver strcmp() {
@@ -231,8 +259,10 @@ private DefaultFunctionResolver strcmp() {
}
/**
- * Returns the rightmost len characters from the string str, or NULL if any argument is NULL.
- * Supports following signatures: (STRING, INTEGER) -> STRING
+ * Returns the rightmost len characters from the string str, or NULL if any argument is
+ * NULL.
+ * Supports following signatures:
+ * (STRING, INTEGER) -> STRING
*/
private DefaultFunctionResolver right() {
return define(
@@ -241,8 +271,10 @@ private DefaultFunctionResolver right() {
}
/**
- * Returns the leftmost len characters from the string str, or NULL if any argument is NULL.
- * Supports following signature: (STRING, INTEGER) -> STRING
+ * Returns the leftmost len characters from the string str, or NULL if any argument is
+ * NULL.
+ * Supports following signature:
+ * (STRING, INTEGER) -> STRING
*/
private DefaultFunctionResolver left() {
return define(
@@ -251,9 +283,11 @@ private DefaultFunctionResolver left() {
}
/**
- * Returns the numeric value of the leftmost character of the string str. Returns 0 if str is the
- * empty string. Returns NULL if str is NULL. ASCII() works for 8-bit characters. Supports
- * following signature: STRING -> INTEGER
+ * Returns the numeric value of the leftmost character of the string str.
+ * Returns 0 if str is the empty string. Returns NULL if str is NULL.
+ * ASCII() works for 8-bit characters.
+ * Supports following signature:
+ * STRING -> INTEGER
*/
private DefaultFunctionResolver ascii() {
return define(
@@ -262,11 +296,14 @@ private DefaultFunctionResolver ascii() {
}
/**
- * LOCATE(substr, str) returns the position of the first occurrence of substring substr in string
- * str. LOCATE(substr, str, pos) returns the position of the first occurrence of substring substr
- * in string str, starting at position pos. Returns 0 if substr is not in str. Returns NULL if any
- * argument is NULL. Supports following signature: (STRING, STRING) -> INTEGER (STRING, STRING,
- * INTEGER) -> INTEGER
+ * LOCATE(substr, str) returns the position of the first occurrence of substring substr
+ * in string str. LOCATE(substr, str, pos) returns the position of the first occurrence
+ * of substring substr in string str, starting at position pos.
+ * Returns 0 if substr is not in str.
+ * Returns NULL if any argument is NULL.
+ * Supports following signature:
+ * (STRING, STRING) -> INTEGER
+ * (STRING, STRING, INTEGER) -> INTEGER
*/
private DefaultFunctionResolver locate() {
return define(
@@ -288,9 +325,12 @@ private DefaultFunctionResolver locate() {
}
/**
- * Returns the position of the first occurrence of a substring in a string starting from 1.
- * Returns 0 if substring is not in string. Returns NULL if any argument is NULL. Supports
- * following signature: (STRING IN STRING) -> INTEGER
+ * Returns the position of the first occurrence of a substring in a string starting from 1.
+ *
+ * Returns 0 if substring is not in string.
+ * Returns NULL if any argument is NULL.
+ * Supports following signature:
+ * (STRING IN STRING) -> INTEGER
*/
private DefaultFunctionResolver position() {
return define(
@@ -304,9 +344,11 @@ private DefaultFunctionResolver position() {
}
/**
- * REPLACE(str, from_str, to_str) returns the string str with all occurrences of the string
- * from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when
- * searching for from_str. Supports following signature: (STRING, STRING, STRING) -> STRING
+ * REPLACE(str, from_str, to_str) returns the string str with all occurrences of
+ * the string from_str replaced by the string to_str.
+ * REPLACE() performs a case-sensitive match when searching for from_str.
+ * Supports following signature:
+ * (STRING, STRING, STRING) -> STRING
*/
private DefaultFunctionResolver replace() {
return define(
@@ -315,8 +357,10 @@ private DefaultFunctionResolver replace() {
}
/**
- * REVERSE(str) returns reversed string of the string supplied as an argument Returns NULL if the
- * argument is NULL. Supports the following signature: (STRING) -> STRING
+ * REVERSE(str) returns reversed string of the string supplied as an argument
+ * Returns NULL if the argument is NULL.
+ * Supports the following signature:
+ * (STRING) -> STRING
*/
private DefaultFunctionResolver reverse() {
return define(
diff --git a/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java b/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java
index f323494307..73f0734953 100644
--- a/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java
+++ b/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java
@@ -13,9 +13,14 @@ public interface WindowFunctionExpression extends Expression {
/**
* Create specific window frame based on window definition and what's current window function. For
- * now two types of cumulative window frame is returned: 1. Ranking window functions: ignore frame
- * definition and always operates on previous and current row. 2. Aggregate window functions:
- * frame partition into peers and sliding window is not supported.
+ * now two types of cumulative window frame is returned:
+ *
+ *
+ * - Ranking window functions: ignore frame definition and always operates on previous and
+ * current row.
+ *
- Aggregate window functions: frame partition into peers and sliding window is not
+ * supported.
+ *
*
* @param definition window definition
* @return window frame
diff --git a/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java b/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java
index 0ec2042b1e..a98826d333 100644
--- a/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java
+++ b/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java
@@ -48,7 +48,7 @@ public boolean hasNext() {
/**
* Move position and clear new partition flag. Note that because all peer rows have same result
* from window function, this is only returned at first time to change window function state.
- * Afterwards, empty list is returned to avoid changes until next peer loaded.
+ * Afterward, empty list is returned to avoid changes until next peer loaded.
*
* @return all rows for the peer
*/
@@ -75,8 +75,14 @@ public ExprValue current() {
/**
* Preload all peer rows if last peer rows done. Note that when no more data in peeking iterator,
* there must be rows in frame (hasNext()=true), so no need to check it.hasNext() in this method.
- * Load until: 1. Different peer found (row with different sort key) 2. Or new partition (row with
- * different partition key) 3. Or no more rows
+ *
+ * Load until:
+ *
+ *
+ * - Different peer found (row with different sort key)
+ *
- Or new partition (row with different partition key)
+ *
- Or no more rows
+ *
*
* @param it rows iterator
*/
diff --git a/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java b/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java
index 85bc937969..657f63e4c9 100644
--- a/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java
+++ b/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java
@@ -14,11 +14,16 @@
/**
* Window frame that represents a subset of a window which is all data accessible to the window
- * function when calculation. Basically there are 3 types of window frame: 1) Entire window frame
- * that holds all data of the window 2) Cumulative window frame that accumulates one row by another
- * 3) Sliding window frame that maintains a sliding window of fixed size Note that which type of
- * window frame is used is determined by both window function itself and frame definition in a
- * window definition.
+ * function when calculation. Basically there are 3 types of window frame:
+ *
+ *
+ * - Entire window frame that holds all data of the window
+ *
- Cumulative window frame that accumulates one row by another
+ *
- Sliding window frame that maintains a sliding window of fixed size
+ *
+ *
+ * Note that which type of window frame is used is determined by both window function itself and
+ * frame definition in a window definition.
*/
public interface WindowFrame extends Environment, Iterator> {
diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java b/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java
index 73eb297fea..4eb16924c4 100644
--- a/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java
+++ b/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java
@@ -150,7 +150,8 @@ public void updateDataSourceMetadata(DataSourceMetadata dataSourceMetadata) {
throw new RuntimeException(e);
}
- if (updateResponse.getResult().equals(DocWriteResponse.Result.UPDATED)) {
+ if (updateResponse.getResult().equals(DocWriteResponse.Result.UPDATED)
+ || updateResponse.getResult().equals(DocWriteResponse.Result.NOOP)) {
LOG.debug("DatasourceMetadata : {} successfully updated", dataSourceMetadata.getName());
} else {
throw new RuntimeException(
diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java
index cc663d56e6..7d41737b2d 100644
--- a/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java
+++ b/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java
@@ -451,6 +451,24 @@ public void testUpdateDataSourceMetadata() {
Mockito.verify(client.threadPool().getThreadContext(), Mockito.times(1)).stashContext();
}
+ @Test
+ public void testUpdateDataSourceMetadataWithNOOP() {
+ Mockito.when(encryptor.encrypt("secret_key")).thenReturn("secret_key");
+ Mockito.when(encryptor.encrypt("access_key")).thenReturn("access_key");
+ Mockito.when(client.update(ArgumentMatchers.any())).thenReturn(updateResponseActionFuture);
+ Mockito.when(updateResponseActionFuture.actionGet()).thenReturn(updateResponse);
+ Mockito.when(updateResponse.getResult()).thenReturn(DocWriteResponse.Result.NOOP);
+ DataSourceMetadata dataSourceMetadata = getDataSourceMetadata();
+
+ this.openSearchDataSourceMetadataStorage.updateDataSourceMetadata(dataSourceMetadata);
+
+ Mockito.verify(encryptor, Mockito.times(1)).encrypt("secret_key");
+ Mockito.verify(encryptor, Mockito.times(1)).encrypt("access_key");
+ Mockito.verify(client.admin().indices(), Mockito.times(0)).create(ArgumentMatchers.any());
+ Mockito.verify(client, Mockito.times(1)).update(ArgumentMatchers.any());
+ Mockito.verify(client.threadPool().getThreadContext(), Mockito.times(1)).stashContext();
+ }
+
@Test
public void testUpdateDataSourceMetadataWithNotFoundResult() {
Mockito.when(encryptor.encrypt("secret_key")).thenReturn("secret_key");