Skip to content

Commit 2751320

Browse files
authored
Fix: correct ATAN(x, y) and CONV(x, a, b) functions bug (opensearch-project#3748)
* Fix: correct ATAN(x, y) and CONV(x, a, b) functions bug Signed-off-by: Hao <haoxinyu@842f57420e85.ant.amazon.com> Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * Fix: correct ATAN(x, y) and CONV(x, a, b) functions bug Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * Fix: correct atan convolution bug and enable tests Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * Fix: correct ATAN(x, y) and CONV(x, a, b) functions bug and enable tests Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> --------- Signed-off-by: Hao <haoxinyu@842f57420e85.ant.amazon.com> Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
1 parent a0ab339 commit 2751320

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

core/src/main/java/org/opensearch/sql/expression/function/PPLFuncImpTable.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,11 @@ void populate() {
832832
builder.makeLiteral(" "),
833833
arg),
834834
PPLTypeChecker.family(SqlTypeFamily.STRING)));
835+
register(
836+
ATAN,
837+
createFunctionImpWithTypeChecker(
838+
(builder, arg1, arg2) -> builder.makeCall(SqlStdOperatorTable.ATAN2, arg1, arg2),
839+
PPLTypeChecker.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)));
835840
register(
836841
STRCMP,
837842
createFunctionImpWithTypeChecker(

core/src/main/java/org/opensearch/sql/expression/function/udf/math/ConvFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public Expression implement(
5757
Expression toBase = translatedOperands.get(2);
5858
if (numberType.getFamily() == SqlTypeFamily.NUMERIC) {
5959
// Convert the first operand to String
60-
number = Expressions.call(Object.class, "toString", number);
60+
number = Expressions.call(Expressions.box(number), "toString");
6161
}
6262
return Expressions.call(ConvImplementor.class, "conv", number, fromBase, toBase);
6363
}

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMathematicalFunctionIT.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
package org.opensearch.sql.calcite.remote;
77

8-
import java.io.IOException;
9-
import org.junit.Ignore;
108
import org.opensearch.sql.ppl.MathematicalFunctionIT;
119

1210
public class CalciteMathematicalFunctionIT extends MathematicalFunctionIT {
@@ -16,16 +14,4 @@ public void init() throws Exception {
1614
enableCalcite();
1715
disallowCalciteFallback();
1816
}
19-
20-
@Override
21-
@Ignore("https://github.com/opensearch-project/sql/issues/3672")
22-
public void testAtan() throws IOException {
23-
super.testAtan();
24-
}
25-
26-
@Override
27-
@Ignore("https://github.com/opensearch-project/sql/issues/3672")
28-
public void testConv() throws IOException {
29-
super.testConv();
30-
}
3117
}

0 commit comments

Comments
 (0)