本文整理汇总了Java中org.apache.calcite.rex.RexCall类的典型用法代码示例。如果您正苦于以下问题:Java RexCall类的具体用法?Java RexCall怎么用?Java RexCall使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RexCall类属于org.apache.calcite.rex包,在下文中一共展示了RexCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFunction
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
private LogicalExpression doFunction(RexCall call, String funcName) {
List<LogicalExpression> args = Lists.newArrayList();
for(RexNode r : call.getOperands()){
args.add(r.accept(this));
}
if (FunctionCallFactory.isBooleanOperator(funcName)) {
LogicalExpression func = FunctionCallFactory.createBooleanOperator(funcName, args);
return func;
} else {
args = Lists.reverse(args);
LogicalExpression lastArg = args.get(0);
for(int i = 1; i < args.size(); i++){
lastArg = FunctionCallFactory.createExpression(funcName, Lists.newArrayList(args.get(i), lastArg));
}
return lastArg;
}
}
示例2: getDistributionMap
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
private Map<Integer, Integer> getDistributionMap(DrillProjectRel project) {
Map<Integer, Integer> m = new HashMap<Integer, Integer>();
for (Ord<RexNode> node : Ord.zip(project.getProjects())) {
// For distribution, either $0 or cast($0 as ...) would keep the distribution after projection.
if (node.e instanceof RexInputRef) {
m.put( ((RexInputRef) node.e).getIndex(), node.i);
} else if (node.e.isA(SqlKind.CAST)) {
RexNode operand = ((RexCall) node.e).getOperands().get(0);
if (operand instanceof RexInputRef) {
m.put(((RexInputRef) operand).getIndex(), node.i);
}
}
}
return m;
}
示例3: visitCall
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Override
public PathSegment visitCall(RexCall call) {
if ("ITEM".equals(call.getOperator().getName())) {
PathSegment mapOrArray = call.operands.get(0).accept(this);
if (mapOrArray != null) {
if (call.operands.get(1) instanceof RexLiteral) {
return mapOrArray.cloneWithNewChild(convertLiteral((RexLiteral) call.operands.get(1)));
}
return mapOrArray;
}
} else {
for (RexNode operand : call.operands) {
addColumn(operand.accept(this));
}
}
return null;
}
示例4: visitCall
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
public RexNode visitCall(RexCall call) {
String functionName = call.getOperator().getName();
List<RexNode> newOps = new ArrayList();
for (RexNode operand : call.operands) {
newOps.add(operand.accept(this));
}
if (funcReg.isFunctionComplexOutput(functionName) ) {
RexBuilder builder = new RexBuilder(factory);
RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex);
lastUsedIndex++;
complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps));
return ret;
}
return call.clone(call.getType(), newOps);
}
示例5: getSimpleFieldCount
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
private int getSimpleFieldCount() {
int cnt = 0;
final ComplexFieldWithNamedSegmentIdentifier complexFieldIdentifer = new ComplexFieldWithNamedSegmentIdentifier();
// SimpleField, either column name, or complex field reference with only named segment ==> no array segment
// a, a.b.c are simple fields.
// a[1].b.c, a.b[1], a.b.c[1] are not simple fields, since they all contain array segment.
// a + b, a * 10 + b, etc are not simple fields, since they are expressions.
for (RexNode expr : this.getProjects()) {
if (expr instanceof RexInputRef) {
// Simple Field reference.
cnt ++;
} else if (expr instanceof RexCall && expr.accept(complexFieldIdentifer)) {
// Complex field with named segments only.
cnt ++;
}
}
return cnt;
}
示例6: visitCall
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Override
public Boolean visitCall(RexCall call) {
if (call.getOperator() == SqlStdOperatorTable.ITEM) {
final RexNode op0 = call.getOperands().get(0);
final RexNode op1 = call.getOperands().get(1);
if (op0 instanceof RexInputRef &&
op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
return true;
} else if (op0 instanceof RexCall &&
op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
return op0.accept(this);
}
}
return false;
}
示例7: findItemInputRefIndex
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
private static int findItemInputRefIndex(RexNode rexNode) {
if (rexNode == null) {
return -1;
}
if (rexNode instanceof RexInputRef) {
return ((RexInputRef) rexNode).getIndex();
}
if (rexNode instanceof RexCall) {
String functionName = ((RexCall) rexNode).getOperator().getName();
if (functionName.equalsIgnoreCase("item")) {
return findItemInputRefIndex(((RexCall) rexNode).getOperands().get(0));
}
}
return -1;
}
示例8: getDistributionMap
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
private Map<Integer, Integer> getDistributionMap(ProjectRel project) {
Map<Integer, Integer> m = new HashMap<Integer, Integer>();
for (Ord<RexNode> node : Ord.zip(project.getProjects())) {
// For distribution, either $0 or cast($0 as ...) would keep the distribution after projection.
if (node.e instanceof RexInputRef) {
m.put( ((RexInputRef) node.e).getIndex(), node.i);
} else if (node.e.isA(SqlKind.CAST)) {
RexNode operand = ((RexCall) node.e).getOperands().get(0);
if (operand instanceof RexInputRef) {
m.put(((RexInputRef) operand).getIndex(), node.i);
}
}
}
return m;
}
示例9: visitCall
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
String functionName = call.getOperator().getName();
List<RexNode> newOps = new ArrayList<>();
for (RexNode operand : call.operands) {
newOps.add(operand.accept(this));
}
if (funcReg.isFunctionComplexOutput(functionName)) {
RexNode ret = builder.makeInputRef( factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), lastUsedIndex);
lastUsedIndex++;
complexExprs.add(call.clone(factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), newOps));
return ret;
}
return call.clone(call.getType(), newOps);
}
示例10: findTopComplexFunc
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
/**
* Find the list of expressions where Complex type function is at top level.
*/
private static List<RexNode> findTopComplexFunc(FunctionImplementationRegistry funcReg, List<RexNode> exprs) {
final List<RexNode> topComplexFuncs = new ArrayList<>();
for (RexNode exp : exprs) {
if (exp instanceof RexCall) {
RexCall call = (RexCall) exp;
String functionName = call.getOperator().getName();
if (funcReg.isFunctionComplexOutput(functionName) ) {
topComplexFuncs.add(exp);
}
}
}
return topComplexFuncs;
}
示例11: simpleLiteralEquality
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Test
public void simpleLiteralEquality(){
final RexNode node = builder.makeCall(SqlStdOperatorTable.EQUALS,
builder.makeBigintLiteral(BigDecimal.ONE),
builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0)
);
FindSimpleFilters finder = new FindSimpleFilters(builder);
StateHolder holder = node.accept(finder);
ImmutableList<RexCall> conditions = holder.getConditions();
assertEquals(1, conditions.size());
assertFalse(holder.hasRemainingExpression());
}
示例12: halfTree
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Test
public void halfTree(){
final RexNode node =
builder.makeCall(SqlStdOperatorTable.AND,
builder.makeCall(SqlStdOperatorTable.EQUALS,
builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
builder.makeBigintLiteral(BigDecimal.ONE)
),
builder.makeApproxLiteral(BigDecimal.ONE)
);
FindSimpleFilters finder = new FindSimpleFilters(builder);
StateHolder holder = node.accept(finder);
ImmutableList<RexCall> conditions = holder.getConditions();
assertEquals(1, conditions.size());
assertEquals(SqlKind.EQUALS, conditions.get(0).getKind());
assertEquals(SqlKind.LITERAL, holder.getNode().getKind());
assertTrue(holder.hasRemainingExpression());
}
示例13: noOnOr
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Test
public void noOnOr(){
final RexNode node =
builder.makeCall(SqlStdOperatorTable.OR,
builder.makeCall(SqlStdOperatorTable.EQUALS,
builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
builder.makeBigintLiteral(BigDecimal.ONE)
),
builder.makeApproxLiteral(BigDecimal.ONE)
);
FindSimpleFilters finder = new FindSimpleFilters(builder);
StateHolder holder = node.accept(finder);
ImmutableList<RexCall> conditions = holder.getConditions();
assertEquals(0, conditions.size());
assertTrue(holder.hasRemainingExpression());
}
示例14: doubleAnd
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Test
public void doubleAnd(){
final RexNode node =
builder.makeCall(SqlStdOperatorTable.AND,
builder.makeCall(SqlStdOperatorTable.EQUALS,
builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
builder.makeBigintLiteral(BigDecimal.ONE)
),
builder.makeCall(SqlStdOperatorTable.EQUALS,
builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
builder.makeBigintLiteral(BigDecimal.ONE)
)
);
FindSimpleFilters finder = new FindSimpleFilters(builder);
StateHolder holder = node.accept(finder);
ImmutableList<RexCall> conditions = holder.getConditions();
assertEquals(2, conditions.size());
assertEquals(SqlKind.EQUALS, conditions.get(0).getKind());
assertEquals(SqlKind.EQUALS, conditions.get(1).getKind());
assertFalse(holder.hasRemainingExpression());
}
示例15: equalityWithCast
import org.apache.calcite.rex.RexCall; //导入依赖的package包/类
@Test
public void equalityWithCast(){
final RexNode node = builder.makeCall(SqlStdOperatorTable.EQUALS,
builder.makeCast(
factory.createSqlType(SqlTypeName.ANY),
builder.makeBigintLiteral(BigDecimal.ONE)
),
builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0)
);
FindSimpleFilters finder = new FindSimpleFilters(builder);
StateHolder holder = node.accept(finder);
ImmutableList<RexCall> conditions = holder.getConditions();
assertEquals(1, conditions.size());
assertEquals(SqlKind.EQUALS, conditions.get(0).getKind());
// Make sure CAST was removed
assertEquals(SqlKind.LITERAL, conditions.get(0).getOperands().get(0).getKind());
assertFalse(holder.hasRemainingExpression());
}