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

[Feat](Nereids) add numeric functions #40744

Merged
merged 10 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public String getStringValueInFe(FormatOptions options) {
String timeStr = getStringValue();
return timeStr.substring(1, timeStr.length() - 1);
} else {
if (Double.isInfinite(getValue())) {
return Double.toString(getValue());
}
return BigDecimal.valueOf(getValue()).toPlainString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
package org.apache.doris.nereids.trees.expressions;

import org.apache.doris.catalog.Env;
import org.apache.doris.nereids.exceptions.NotSupportedException;
import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
import org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeAcquire;
import org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeArithmetic;
import org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeExtractAndTransform;
import org.apache.doris.nereids.trees.expressions.functions.executable.ExecutableFunctions;
import org.apache.doris.nereids.trees.expressions.functions.executable.NumericArithmetic;
import org.apache.doris.nereids.trees.expressions.functions.executable.StringArithmetic;
import org.apache.doris.nereids.trees.expressions.functions.executable.TimeRoundSeries;
Expand Down Expand Up @@ -105,20 +105,24 @@ private Expression invoke(Expression expression, String fnName) {
Class<?> componentType = parameterType.getComponentType();
Object varArgs = Array.newInstance(componentType, inputSize - fixedArgsSize);
for (int i = fixedArgsSize; i < inputSize; i++) {
if (!(expression.children().get(i) instanceof NullLiteral)) {
Array.set(varArgs, i - fixedArgsSize, expression.children().get(i));
}
Array.set(varArgs, i - fixedArgsSize, expression.children().get(i));
}
Object[] objects = new Object[fixedArgsSize + 1];
for (int i = 0; i < fixedArgsSize; i++) {
objects[i] = expression.children().get(i);
}
objects[fixedArgsSize] = varArgs;

return (Literal) method.invoke(null, varArgs);
return (Literal) method.invoke(null, objects);
}
return (Literal) method.invoke(null, expression.children().toArray());
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof NotSupportedException) {
throw new NotSupportedException(e.getTargetException().getMessage());
} else {
return expression;
}
} catch (IllegalAccessException | IllegalArgumentException e) {
return expression;
}
}
Expand Down Expand Up @@ -192,7 +196,6 @@ private void registerFunctions() {
List<Class<?>> classes = ImmutableList.of(
DateTimeAcquire.class,
DateTimeExtractAndTransform.class,
ExecutableFunctions.class,
DateLiteral.class,
DateTimeArithmetic.class,
NumericArithmetic.class,
Expand Down

This file was deleted.

Loading
Loading