File tree Expand file tree Collapse file tree
core/src/main/java/org/opensearch/sql/expression/function Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5151import org .opensearch .sql .expression .function .udf .math .DivideFunction ;
5252import org .opensearch .sql .expression .function .udf .math .EulerFunction ;
5353import org .opensearch .sql .expression .function .udf .math .ModFunction ;
54- import org .opensearch .sql .expression .function .udf .math .SqrtFunction ;
5554import org .opensearch .sql .expression .function .udf .text .LocateFunction ;
5655
5756/** Defines functions and operators that are implemented only by PPL */
@@ -60,7 +59,6 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
6059 // Math functions
6160 public static final SqlOperator SPAN = new SpanFunctionImpl ().toUDF ("SPAN" );
6261 public static final SqlOperator E = new EulerFunction ().toUDF ("E" );
63- public static final SqlOperator SQRT = new SqrtFunction ().toUDF ("SQRT" );
6462 public static final SqlOperator CONV = new ConvFunction ().toUDF ("CONVERT" );
6563 public static final SqlOperator MOD = new ModFunction ().toUDF ("MOD" );
6664 public static final SqlOperator CRC32 = new CRC32Function ().toUDF ("CRC32" );
Original file line number Diff line number Diff line change @@ -218,10 +218,6 @@ void populate() {
218218 // Register PPL UDF operator
219219 registerOperator (SPAN , PPLBuiltinOperators .SPAN );
220220 registerOperator (E , PPLBuiltinOperators .E );
221-
222- // SqlStdOperatorTable.SQRT is declared but not implemented, therefore we use a custom
223- // implementation.
224- registerOperator (SQRT , PPLBuiltinOperators .SQRT );
225221 registerOperator (CONV , PPLBuiltinOperators .CONV );
226222 registerOperator (MOD , PPLBuiltinOperators .MOD );
227223 registerOperator (MODULUS , PPLBuiltinOperators .MOD );
@@ -347,6 +343,16 @@ void populate() {
347343 SqlLibraryOperators .LOG ,
348344 arg ,
349345 builder .makeApproxLiteral (BigDecimal .valueOf (Math .E )))));
346+ // SqlStdOperatorTable.SQRT is declared but not implemented. The call to SQRT in Calcite is
347+ // converted to POWER(x, 0.5).
348+ register (
349+ SQRT ,
350+ ((FunctionImp1 )
351+ (builder , arg ) ->
352+ builder .makeCall (
353+ SqlStdOperatorTable .POWER ,
354+ arg ,
355+ builder .makeApproxLiteral (BigDecimal .valueOf (0.5 )))));
350356 register (
351357 TYPEOF ,
352358 (FunctionImp1 )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments