Java Code Examples for org.apache.calcite.util.mapping.Mapping#getTargetOpt()
The following examples show how to use
org.apache.calcite.util.mapping.Mapping#getTargetOpt() .
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: AbstractMaterializedViewRule.java From Bats with Apache License 2.0 | 6 votes |
/** * Replaces all the input references by the position in the * input column set. If a reference index cannot be found in * the input set, then we return null. */ private static RexNode shuttleReferences(final RexBuilder rexBuilder, final RexNode node, final Mapping mapping) { try { RexShuttle visitor = new RexShuttle() { @Override public RexNode visitInputRef(RexInputRef inputRef) { int pos = mapping.getTargetOpt(inputRef.getIndex()); if (pos != -1) { // Found it return rexBuilder.makeInputRef(inputRef.getType(), pos); } throw Util.FoundOne.NULL; } }; return visitor.apply(node); } catch (Util.FoundOne ex) { Util.swallow(ex, null); return null; } }
Example 2
Source File: MaterializedViewRule.java From calcite with Apache License 2.0 | 6 votes |
/** * Replaces all the input references by the position in the * input column set. If a reference index cannot be found in * the input set, then we return null. */ protected RexNode shuttleReferences(final RexBuilder rexBuilder, final RexNode node, final Mapping mapping) { try { RexShuttle visitor = new RexShuttle() { @Override public RexNode visitInputRef(RexInputRef inputRef) { int pos = mapping.getTargetOpt(inputRef.getIndex()); if (pos != -1) { // Found it return rexBuilder.makeInputRef(inputRef.getType(), pos); } throw Util.FoundOne.NULL; } }; return visitor.apply(node); } catch (Util.FoundOne ex) { Util.swallow(ex, null); return null; } }