PHILO-HE commented on code in PR #10095:
URL:
https://github.com/apache/incubator-gluten/pull/10095#discussion_r2241432796
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/BaseRexCallConverters.java:
##########
@@ -62,6 +62,14 @@ public DefaultRexCallConverter(String functionName) {
public TypedExpr toTypedExpr(RexCall callNode, RexConversionContext context)
{
List<TypedExpr> params = getParams(callNode, context);
Type resultType = getResultType(callNode);
+ // TODO: cast don't support input and result has same type. Refine it.
+ if (functionName.equals("cast")
+ && resultType
+ .getClass()
+ .getName()
+ .equals(params.get(0).getReturnType().getClass().getName())) {
Review Comment:
Maybe, just compare `resultType.getClass() ==
params.get(0).getReturnType().getClass()`.
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/BaseRexCallConverters.java:
##########
@@ -62,6 +62,14 @@ public DefaultRexCallConverter(String functionName) {
public TypedExpr toTypedExpr(RexCall callNode, RexConversionContext context)
{
List<TypedExpr> params = getParams(callNode, context);
Type resultType = getResultType(callNode);
+ // TODO: cast don't support input and result has same type. Refine it.
Review Comment:
Is it necessary to support same type cast in Velox? Seems the cast operation
can be eliminated if unnecessary.
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/DataTimeRexCallConvertor.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gluten.rexnode.functions;
+
+import org.apache.gluten.rexnode.RexConversionContext;
+import org.apache.gluten.rexnode.RexNodeConverter;
+
+import io.github.zhztheplayer.velox4j.expression.CallTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.CastTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.TypedExpr;
+import io.github.zhztheplayer.velox4j.type.BigIntType;
+import io.github.zhztheplayer.velox4j.type.TimestampType;
+import io.github.zhztheplayer.velox4j.type.Type;
+
+import org.apache.calcite.rex.RexCall;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+class TimeStampIntervalRexCallConverter extends BaseRexCallConverter {
+
+ public TimeStampIntervalRexCallConverter(String functionName) {
+ super(functionName);
+ }
+
+ @Override
+ public boolean isSupported(RexCall callNode, RexConversionContext context) {
+ // This converter supports timestamp and interval day-time operations.
Review Comment:
Seems interval types are actually excluded in the implementation below. If
so, please revise the comment.
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/DataTimeRexCallConvertor.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gluten.rexnode.functions;
+
+import org.apache.gluten.rexnode.RexConversionContext;
+import org.apache.gluten.rexnode.RexNodeConverter;
+
+import io.github.zhztheplayer.velox4j.expression.CallTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.CastTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.TypedExpr;
+import io.github.zhztheplayer.velox4j.type.BigIntType;
+import io.github.zhztheplayer.velox4j.type.TimestampType;
+import io.github.zhztheplayer.velox4j.type.Type;
+
+import org.apache.calcite.rex.RexCall;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+class TimeStampIntervalRexCallConverter extends BaseRexCallConverter {
+
+ public TimeStampIntervalRexCallConverter(String functionName) {
+ super(functionName);
+ }
+
+ @Override
+ public boolean isSupported(RexCall callNode, RexConversionContext context) {
+ // This converter supports timestamp and interval day-time operations.
+ List<Type> operandTypes =
+ callNode.getOperands().stream()
+ .map(param -> RexNodeConverter.toType(param.getType()))
+ .collect(Collectors.toList());
+ return (operandTypes.get(0) instanceof TimestampType
+ // && TypeUtils.isTimeInterval(operandTypes.get(1)))
+ || // (TypeUtils.isTimeInterval(operandTypes.get(0)) &&
+ operandTypes.get(1) instanceof TimestampType);
+ }
+
+ @Override
+ public TypedExpr toTypedExpr(RexCall callNode, RexConversionContext context)
{
+ List<TypedExpr> params = getParams(callNode, context);
+ Type resultType = getResultType(callNode);
+ // TODO: for comparison, should return boolean. Refine it.
+ if (!resultType.getClass().getSimpleName().equals("BooleanType")) {
Review Comment:
For simplicity, `resultType instanceof BooleanType`
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/DataTimeRexCallConvertor.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gluten.rexnode.functions;
+
+import org.apache.gluten.rexnode.RexConversionContext;
+import org.apache.gluten.rexnode.RexNodeConverter;
+
+import io.github.zhztheplayer.velox4j.expression.CallTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.CastTypedExpr;
+import io.github.zhztheplayer.velox4j.expression.TypedExpr;
+import io.github.zhztheplayer.velox4j.type.BigIntType;
+import io.github.zhztheplayer.velox4j.type.TimestampType;
+import io.github.zhztheplayer.velox4j.type.Type;
+
+import org.apache.calcite.rex.RexCall;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+class TimeStampIntervalRexCallConverter extends BaseRexCallConverter {
Review Comment:
Rename to `TimeStampCompareRexCallConverter` if only for compare operator
conversion and not considering interval types.
##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/functions/BaseRexCallConverters.java:
##########
@@ -62,6 +62,14 @@ public DefaultRexCallConverter(String functionName) {
public TypedExpr toTypedExpr(RexCall callNode, RexConversionContext context)
{
List<TypedExpr> params = getParams(callNode, context);
Type resultType = getResultType(callNode);
+ // TODO: cast don't support input and result has same type. Refine it.
+ if (functionName.equals("cast")
+ && resultType
+ .getClass()
+ .getName()
+ .equals(params.get(0).getReturnType().getClass().getName())) {
Review Comment:
In the latest main branch, maybe, the code below can be removed if it's
included here.
```
if (sourceType instanceof TimestampType && resultType instanceof
TimestampType) {
return sourceExpr;
}
```
--
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]