Java Code Examples for org.apache.calcite.rel.logical.LogicalFilter#create()
The following examples show how to use
org.apache.calcite.rel.logical.LogicalFilter#create() .
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: IncrementalUpdateUtils.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public RelNode visit(TableScan tableScan) { if (!(tableScan instanceof IncrementallyUpdateable)) { return tableScan; } final RelNode newScan = updateScan((IncrementallyUpdateable) tableScan); // build new filter to apply refresh condition. final RexBuilder rexBuilder = tableScan.getCluster().getRexBuilder(); RelDataTypeField field = newScan.getRowType().getField(UPDATE_COLUMN, false, false); final RexNode inputRef = rexBuilder.makeInputRef(newScan, field.getIndex()); final Optional<RexNode> literal = generateLiteral(rexBuilder, tableScan.getCluster().getTypeFactory(), field.getType().getSqlTypeName()); if (literal.isPresent()) { RexNode condition = tableScan.getCluster().getRexBuilder().makeCall(SqlStdOperatorTable.GREATER_THAN, ImmutableList.of(inputRef, literal.get())); return LogicalFilter.create(newScan, condition); } return newScan; }
Example 2
Source File: MockCatalogReader.java From calcite with Apache License 2.0 | 6 votes |
@Override public RelNode toRel(ToRelContext context) { RelNode rel = LogicalTableScan.create(context.getCluster(), fromTable, context.getTableHints()); final RexBuilder rexBuilder = context.getCluster().getRexBuilder(); rel = LogicalFilter.create( rel, getConstraint(rexBuilder, rel.getRowType())); final List<RelDataTypeField> fieldList = rel.getRowType().getFieldList(); final List<Pair<RexNode, String>> projects = new AbstractList<Pair<RexNode, String>>() { @Override public Pair<RexNode, String> get(int index) { return RexInputRef.of2(mapping.get(index), fieldList); } @Override public int size() { return mapping.size(); } }; return LogicalProject.create(rel, ImmutableList.of(), Pair.left(projects), Pair.right(projects)); }
Example 3
Source File: StreamRules.java From Bats with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Filter filter = call.rel(1); final LogicalDelta newDelta = LogicalDelta.create(filter.getInput()); final LogicalFilter newFilter = LogicalFilter.create(newDelta, filter.getCondition()); call.transformTo(newFilter); }
Example 4
Source File: QuarkTileTable.java From quark with Apache License 2.0 | 5 votes |
public RelNode toRel( RelOptTable.ToRelContext context, RelOptTable relOptTable) { // Request all fields. RelNode rel = new QuarkTileScan(context.getCluster(), this.relOptTable, this.quarkTile, this.backingTable); //Create a filter RexBuilder rexBuilder = rel.getCluster().getRexBuilder(); List<RexNode> filterArgs = Lists.newArrayList(); filterArgs.add(rexBuilder.makeInputRef(rel, this.quarkTile.groupingColumn)); filterArgs.add(rexBuilder.makeLiteral(bitSetToString(this.quarkTile.groupingValue))); rel = LogicalFilter.create(rel, rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, filterArgs)); //Create a project list List<Integer> posList = Lists.newArrayList(); for (QuarkTile.Column quarkColumn : this.quarkTile.cubeColumns) { posList.add(quarkColumn.cubeOrdinal); } for (Lattice.Measure measure : this.quarkTile.measures) { posList.add(((QuarkTile.Measure) measure).ordinal); } return RelOptUtil.createProject(rel, posList); }
Example 5
Source File: StreamRules.java From calcite with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); Util.discard(delta); final Filter filter = call.rel(1); final LogicalDelta newDelta = LogicalDelta.create(filter.getInput()); final LogicalFilter newFilter = LogicalFilter.create(newDelta, filter.getCondition()); call.transformTo(newFilter); }
Example 6
Source File: RelFactories.java From Bats with Apache License 2.0 | 4 votes |
public RelNode createFilter(RelNode input, RexNode condition) { return LogicalFilter.create(input, condition); }
Example 7
Source File: RelFactories.java From calcite with Apache License 2.0 | 4 votes |
public RelNode createFilter(RelNode input, RexNode condition, Set<CorrelationId> variablesSet) { return LogicalFilter.create(input, condition, ImmutableSet.copyOf(variablesSet)); }
Example 8
Source File: LixToRelTranslator.java From calcite with Apache License 2.0 | 4 votes |
public RelNode translate(Expression expression) { if (expression instanceof MethodCallExpression) { final MethodCallExpression call = (MethodCallExpression) expression; BuiltInMethod method = BuiltInMethod.MAP.get(call.method); if (method == null) { throw new UnsupportedOperationException( "unknown method " + call.method); } RelNode input; switch (method) { case SELECT: input = translate(call.targetExpression); return LogicalProject.create(input, ImmutableList.of(), toRex(input, (FunctionExpression) call.expressions.get(0)), (List<String>) null); case WHERE: input = translate(call.targetExpression); return LogicalFilter.create(input, toRex((FunctionExpression) call.expressions.get(0), input)); case AS_QUERYABLE: return LogicalTableScan.create(cluster, RelOptTableImpl.create(null, typeFactory.createJavaType( Types.toClass( Types.getElementType(call.targetExpression.getType()))), ImmutableList.of(), call.targetExpression), ImmutableList.of()); case SCHEMA_GET_TABLE: return LogicalTableScan.create(cluster, RelOptTableImpl.create(null, typeFactory.createJavaType((Class) ((ConstantExpression) call.expressions.get(1)).value), ImmutableList.of(), call.targetExpression), ImmutableList.of()); default: throw new UnsupportedOperationException( "unknown method " + call.method); } } throw new UnsupportedOperationException( "unknown expression type " + expression.getNodeType()); }