Java Code Examples for org.apache.calcite.rex.RexCall#isA()
The following examples show how to use
org.apache.calcite.rex.RexCall#isA() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelStructuredTypeFlattener.java From Bats with Apache License 2.0 | 6 votes |
@Override public RexNode visitCall(RexCall rexCall) { if (rexCall.isA(SqlKind.CAST)) { RexNode input = rexCall.getOperands().get(0).accept(this); RelDataType targetType = removeDistinct(rexCall.getType()); return rexBuilder.makeCast(targetType, input); } if (!rexCall.isA(SqlKind.COMPARISON)) { return super.visitCall(rexCall); } RexNode lhs = rexCall.getOperands().get(0); if (!lhs.getType().isStruct()) { // NOTE jvs 9-Mar-2005: Calls like IS NULL operate // on the representative null indicator. Since it comes // first, we don't have to do any special translation. return super.visitCall(rexCall); } // NOTE jvs 22-Mar-2005: Likewise, the null indicator takes // care of comparison null semantics without any special casing. return flattenComparison(rexBuilder, rexCall.getOperator(), rexCall.getOperands()); }
Example 2
Source File: RelMdUtil.java From Bats with Apache License 2.0 | 5 votes |
public Double visitCall(RexCall call) { Double distinctRowCount; Double rowCount = mq.getRowCount(rel); if (call.isA(SqlKind.MINUS_PREFIX)) { distinctRowCount = cardOfProjExpr(mq, rel, call.getOperands().get(0)); } else if (call.isA(ImmutableList.of(SqlKind.PLUS, SqlKind.MINUS))) { Double card0 = cardOfProjExpr(mq, rel, call.getOperands().get(0)); if (card0 == null) { return null; } Double card1 = cardOfProjExpr(mq, rel, call.getOperands().get(1)); if (card1 == null) { return null; } distinctRowCount = Math.max(card0, card1); } else if (call.isA(ImmutableList.of(SqlKind.TIMES, SqlKind.DIVIDE))) { distinctRowCount = NumberUtil.multiply( cardOfProjExpr(mq, rel, call.getOperands().get(0)), cardOfProjExpr(mq, rel, call.getOperands().get(1))); // TODO zfong 6/21/06 - Broadbase has code to handle date // functions like year, month, day; E.g., cardinality of Month() // is 12 } else { if (call.getOperands().size() == 1) { distinctRowCount = cardOfProjExpr(mq, rel, call.getOperands().get(0)); } else { distinctRowCount = rowCount / 10; } } return numDistinctVals(distinctRowCount, rowCount); }
Example 3
Source File: RelStructuredTypeFlattener.java From Bats with Apache License 2.0 | 5 votes |
private boolean isConstructor(RexNode rexNode) { // TODO jvs 11-Feb-2005: share code with SqlToRelConverter if (!(rexNode instanceof RexCall)) { return false; } RexCall call = (RexCall) rexNode; return call.getOperator().getName().equalsIgnoreCase("row") || (call.isA(SqlKind.NEW_SPECIFICATION)); }
Example 4
Source File: RelMdUtil.java From calcite with Apache License 2.0 | 5 votes |
public Double visitCall(RexCall call) { Double distinctRowCount; Double rowCount = mq.getRowCount(rel); if (call.isA(SqlKind.MINUS_PREFIX)) { distinctRowCount = cardOfProjExpr(mq, rel, call.getOperands().get(0)); } else if (call.isA(ImmutableList.of(SqlKind.PLUS, SqlKind.MINUS))) { Double card0 = cardOfProjExpr(mq, rel, call.getOperands().get(0)); if (card0 == null) { return null; } Double card1 = cardOfProjExpr(mq, rel, call.getOperands().get(1)); if (card1 == null) { return null; } distinctRowCount = Math.max(card0, card1); } else if (call.isA(ImmutableList.of(SqlKind.TIMES, SqlKind.DIVIDE))) { distinctRowCount = NumberUtil.multiply( cardOfProjExpr(mq, rel, call.getOperands().get(0)), cardOfProjExpr(mq, rel, call.getOperands().get(1))); // TODO zfong 6/21/06 - Broadbase has code to handle date // functions like year, month, day; E.g., cardinality of Month() // is 12 } else { if (call.getOperands().size() == 1) { distinctRowCount = cardOfProjExpr(mq, rel, call.getOperands().get(0)); } else { distinctRowCount = rowCount / 10; } } return numDistinctVals(distinctRowCount, rowCount); }
Example 5
Source File: RelStructuredTypeFlattener.java From calcite with Apache License 2.0 | 5 votes |
private boolean isConstructor(RexNode rexNode) { // TODO jvs 11-Feb-2005: share code with SqlToRelConverter if (!(rexNode instanceof RexCall)) { return false; } RexCall call = (RexCall) rexNode; return call.getOperator().getName().equalsIgnoreCase("row") || (call.isA(SqlKind.NEW_SPECIFICATION)); }
Example 6
Source File: ReduceDecimalsRule.java From Bats with Apache License 2.0 | 4 votes |
@Override public boolean canExpand(RexCall call) { return call.isA(SqlKind.REINTERPRET) && call.getOperands().get(0).isA(SqlKind.REINTERPRET); }
Example 7
Source File: SimplifyNLJConditionRule.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public RexNode visitCall(RexCall call, final Pointer<SimplifyNLJConditionRule.Side> sidePointer) { List<RexNode> newOperands = new ArrayList<>(); List<SimplifyNLJConditionRule.Side> sides = new ArrayList<>(); call.getOperands().forEach(o -> { Pointer<SimplifyNLJConditionRule.Side> s = new Pointer<>(); RexNode newOperand = o.accept(this, s); sides.add(s.value); newOperands.add(newOperand); }); RexNode special = handleSpecial(call, sides, sidePointer, rexBuilder); if (special != null) { return special.accept(this, sidePointer); } if (SimplifyNLJConditionRule.Side.shouldPushDown(sides)) { List<RexNode> finalOperands = new ArrayList<>(); for (Pair<RexNode, SimplifyNLJConditionRule.Side> pair : Pair.zip(newOperands, sides)) { if (pair.right == SimplifyNLJConditionRule.Side.LEFT || pair.right == SimplifyNLJConditionRule.Side.RIGHT) { String digest = pair.left.toString(); Integer index = exprMap.get(digest); if (index == null) { index = exprs.size(); exprs.add(pair.left); exprMap.put(digest, index); if (pair.right == SimplifyNLJConditionRule.Side.LEFT) { leftExprs.add(index); } else { rightExprs.add(index); } } finalOperands.add(new RexInputRef(index, pair.left.getType())); } else { finalOperands.add(pair.left); } } sidePointer.value = SimplifyNLJConditionRule.Side.BOTH; return rexBuilder.makeCall(call.getOperator(), finalOperands); } sidePointer.value = SimplifyNLJConditionRule.Side.merge(sides); if (call.isA(SqlKind.CAST)) { return rexBuilder.makeCast(call.getType(), newOperands.get(0)); } return rexBuilder.makeCall(call.getOperator(), newOperands); }
Example 8
Source File: ReduceDecimalsRule.java From calcite with Apache License 2.0 | 4 votes |
public boolean canExpand(RexCall call) { return call.isA(SqlKind.REINTERPRET) && call.operands.get(0).isA(SqlKind.REINTERPRET); }