Skip to content

Commit f2015e5

Browse files
committed
Remove legacy type checking code and update documentation
Delete PPLTypeChecker, CalciteFuncSignature, CoercionUtils (moved to validate/ package), and OpenSearchSparkSqlDialect (moved to core/) which are no longer needed in their original locations after migrating to Calcite's validation system. Update LambdaUtils and CalcitePPLNoMvTest to match final PR state. Update user-facing documentation for the new behavior. Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent a494a06 commit f2015e5

13 files changed

Lines changed: 68 additions & 1321 deletions

File tree

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 0 additions & 274 deletions
This file was deleted.

core/src/main/java/org/opensearch/sql/expression/function/CollectionUDF/LambdaUtils.java

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@
66
package org.opensearch.sql.expression.function.CollectionUDF;
77

88
import java.math.BigDecimal;
9-
import java.util.ArrayList;
10-
import java.util.List;
11-
import java.util.Map;
12-
import org.apache.calcite.rel.type.RelDataType;
13-
import org.apache.calcite.rel.type.RelDataTypeFactory;
14-
import org.apache.calcite.rex.RexCall;
15-
import org.apache.calcite.rex.RexCallBinding;
16-
import org.apache.calcite.rex.RexLambda;
17-
import org.apache.calcite.rex.RexLambdaRef;
18-
import org.apache.calcite.rex.RexNode;
19-
import org.apache.calcite.sql.type.SqlReturnTypeInference;
209
import org.apache.calcite.sql.type.SqlTypeName;
2110

2211
public class LambdaUtils {
@@ -37,58 +26,4 @@ public static Object transferLambdaOutputToTargetType(Object candidate, SqlTypeN
3726
return candidate;
3827
}
3928
}
40-
41-
public static RelDataType inferReturnTypeFromLambda(
42-
RexLambda rexLambda, Map<String, RelDataType> filledTypes, RelDataTypeFactory typeFactory) {
43-
RexCall rexCall = (RexCall) rexLambda.getExpression();
44-
SqlReturnTypeInference returnInfer = rexCall.getOperator().getReturnTypeInference();
45-
List<RexNode> lambdaOperands = rexCall.getOperands();
46-
List<RexNode> filledOperands = new ArrayList<>();
47-
for (RexNode rexNode : lambdaOperands) {
48-
if (rexNode instanceof RexLambdaRef rexLambdaRef) {
49-
if (rexLambdaRef.getType().getSqlTypeName() == SqlTypeName.ANY) {
50-
filledOperands.add(
51-
new RexLambdaRef(
52-
rexLambdaRef.getIndex(),
53-
rexLambdaRef.getName(),
54-
filledTypes.get(rexLambdaRef.getName())));
55-
} else {
56-
filledOperands.add(rexNode);
57-
}
58-
} else if (rexNode instanceof RexCall) {
59-
filledOperands.add(
60-
reInferReturnTypeForRexCallInsideLambda((RexCall) rexNode, filledTypes, typeFactory));
61-
} else {
62-
filledOperands.add(rexNode);
63-
}
64-
}
65-
return returnInfer.inferReturnType(
66-
new RexCallBinding(typeFactory, rexCall.getOperator(), filledOperands, List.of()));
67-
}
68-
69-
public static RexCall reInferReturnTypeForRexCallInsideLambda(
70-
RexCall rexCall, Map<String, RelDataType> argTypes, RelDataTypeFactory typeFactory) {
71-
List<RexNode> filledOperands = new ArrayList<>();
72-
List<RexNode> rexCallOperands = rexCall.getOperands();
73-
for (RexNode rexNode : rexCallOperands) {
74-
if (rexNode instanceof RexLambdaRef rexLambdaRef) {
75-
filledOperands.add(
76-
new RexLambdaRef(
77-
rexLambdaRef.getIndex(),
78-
rexLambdaRef.getName(),
79-
argTypes.get(rexLambdaRef.getName())));
80-
} else if (rexNode instanceof RexCall) {
81-
filledOperands.add(
82-
reInferReturnTypeForRexCallInsideLambda((RexCall) rexNode, argTypes, typeFactory));
83-
} else {
84-
filledOperands.add(rexNode);
85-
}
86-
}
87-
RelDataType returnType =
88-
rexCall
89-
.getOperator()
90-
.inferReturnType(
91-
new RexCallBinding(typeFactory, rexCall.getOperator(), filledOperands, List.of()));
92-
return rexCall.clone(returnType, filledOperands);
93-
}
9429
}

0 commit comments

Comments
 (0)