PHILO-HE commented on code in PR #9536:
URL: https://github.com/apache/incubator-gluten/pull/9536#discussion_r2097435904
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/Utils.java:
##########
@@ -46,4 +56,42 @@ public static void registerRegistry() {
ISerializableRegistry.registerAll();
}
}
+
+ private static final List<Type> NUMBER_TYPE_PRIORITY_LIST = List.of(
+ new TinyIntType(),
+ new SmallIntType(),
+ new IntegerType(),
+ new BigIntType(),
+ new RealType(),
+ new DoubleType()
+ );
+
+ private static int getNumberTypePriority(Type type) {
Review Comment:
Number->Numeric
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/Utils.java:
##########
@@ -46,4 +56,42 @@ public static void registerRegistry() {
ISerializableRegistry.registerAll();
}
}
+
+ private static final List<Type> NUMBER_TYPE_PRIORITY_LIST = List.of(
Review Comment:
NUMBER->NUMERIC
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/Utils.java:
##########
@@ -46,4 +56,42 @@ public static void registerRegistry() {
ISerializableRegistry.registerAll();
}
}
+
+ private static final List<Type> NUMBER_TYPE_PRIORITY_LIST = List.of(
+ new TinyIntType(),
+ new SmallIntType(),
+ new IntegerType(),
+ new BigIntType(),
+ new RealType(),
+ new DoubleType()
+ );
+
+ private static int getNumberTypePriority(Type type) {
+ int index = -1;
+ for (int i = 0; i < NUMBER_TYPE_PRIORITY_LIST.size(); ++i) {
+ if
(NUMBER_TYPE_PRIORITY_LIST.get(i).getClass().equals((type.getClass()))) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
Review Comment:
No need to use index as flag. Just throw exception here as there is no
matching in the loop.
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/RexConversionContext.java:
##########
@@ -14,24 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.gluten.rexnode.functions;
-import io.github.zhztheplayer.velox4j.expression.CallTypedExpr;
-import io.github.zhztheplayer.velox4j.expression.TypedExpr;
-import io.github.zhztheplayer.velox4j.type.Type;
+package org.apache.gluten.rexnode;
import java.util.List;
-/** Default convertor for velox function. */
-public class DefaultFunctionConverter implements FunctionConverter {
- private final String function;
-
- public DefaultFunctionConverter(String function) {
- this.function = function;
+public class RexConversionContext {
+ private final List<String> inputAttributeNames;
+
+ public RexConversionContext(List<String> inputAttributeNames) {
+ this.inputAttributeNames = inputAttributeNames;
}
-
- @Override
- public CallTypedExpr toVeloxFunction(Type nodeType, List<TypedExpr>
params) {
- return new CallTypedExpr(nodeType, params, function);
+ public List<String> getInputAttributeNames() {
+ return inputAttributeNames;
}
-}
+};
Review Comment:
Remove ";"
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/Utils.java:
##########
@@ -46,4 +56,42 @@ public static void registerRegistry() {
ISerializableRegistry.registerAll();
}
}
+
+ private static final List<Type> NUMBER_TYPE_PRIORITY_LIST = List.of(
+ new TinyIntType(),
+ new SmallIntType(),
+ new IntegerType(),
+ new BigIntType(),
+ new RealType(),
+ new DoubleType()
+ );
+
+ private static int getNumberTypePriority(Type type) {
+ int index = -1;
+ for (int i = 0; i < NUMBER_TYPE_PRIORITY_LIST.size(); ++i) {
+ if
(NUMBER_TYPE_PRIORITY_LIST.get(i).getClass().equals((type.getClass()))) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
+ throw new RuntimeException("Unsupported type: " +
type.getClass().getName());
+ }
+ return index;
+ }
+
+ public static List<TypedExpr>
promoteTypeForNumberExpressions(List<TypedExpr> expressions) {
Review Comment:
Assume this is only for arithmetic expressions. So suggest to name this
method like:
promoteTypeForArithmeticExpressions
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/Utils.java:
##########
@@ -46,4 +56,42 @@ public static void registerRegistry() {
ISerializableRegistry.registerAll();
}
}
+
+ private static final List<Type> NUMBER_TYPE_PRIORITY_LIST = List.of(
+ new TinyIntType(),
+ new SmallIntType(),
+ new IntegerType(),
+ new BigIntType(),
+ new RealType(),
+ new DoubleType()
+ );
+
+ private static int getNumberTypePriority(Type type) {
+ int index = -1;
+ for (int i = 0; i < NUMBER_TYPE_PRIORITY_LIST.size(); ++i) {
+ if
(NUMBER_TYPE_PRIORITY_LIST.get(i).getClass().equals((type.getClass()))) {
+ index = i;
+ break;
Review Comment:
Suggestion: directly return i
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/Utils.java:
##########
@@ -46,4 +56,42 @@ public static void registerRegistry() {
ISerializableRegistry.registerAll();
}
}
+
+ private static final List<Type> NUMBER_TYPE_PRIORITY_LIST = List.of(
+ new TinyIntType(),
+ new SmallIntType(),
+ new IntegerType(),
+ new BigIntType(),
+ new RealType(),
+ new DoubleType()
Review Comment:
Since the corresponding class is compared, can we just store class type in
the list?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]