public void visit(RelNode rel, int ordinal, RelNode parent) {
    // REVIEW: SWZ: 1/31/06: We assume that any special RelNodes, such
    // as the VolcanoPlanner's RelSubset always have a full complement
    // of traits and that they either appear as registered or do nothing
    // when childrenAccept is called on them.

    if (planner.isRegistered(rel)) {
      return;
    }

    RelTraitSet relTraits = rel.getTraitSet();
    for (int i = 0; i < baseTraits.size(); i++) {
      if (i >= relTraits.size()) {
        // Copy traits that the new rel doesn't know about.
        Util.discard(RelOptUtil.addTrait(rel, baseTraits.getTrait(i)));

        // FIXME: Return the new rel. We can no longer traits in-place,
        //   because rels and traits are immutable.
        throw new AssertionError();
      } else {
        // Verify that the traits are from the same RelTraitDef
        assert relTraits.getTrait(i).getTraitDef() == baseTraits.getTrait(i).getTraitDef();
      }
    }

    rel.childrenAccept(this);
  }
Пример #2
0
  /** Variant of {@link #trimFields(RelNode, BitSet, Set)} for {@link TableModificationRel}. */
  public TrimResult trimFields(
      TableModificationRel modifier, BitSet fieldsUsed, Set<RelDataTypeField> extraFields) {
    // Ignore what consumer wants. We always project all columns.
    Util.discard(fieldsUsed);

    final RelDataType rowType = modifier.getRowType();
    final int fieldCount = rowType.getFieldCount();
    RelNode input = modifier.getChild();

    // We want all fields from the child.
    final int inputFieldCount = input.getRowType().getFieldCount();
    BitSet inputFieldsUsed = Util.bitSetBetween(0, inputFieldCount);

    // Create input with trimmed columns.
    final Set<RelDataTypeField> inputExtraFields = Collections.emptySet();
    TrimResult trimResult = trimChild(modifier, input, inputFieldsUsed, inputExtraFields);
    RelNode newInput = trimResult.left;
    final Mapping inputMapping = trimResult.right;
    if (!inputMapping.isIdentity()) {
      // We asked for all fields. Can't believe that the child decided
      // to permute them!
      throw Util.newInternal("Expected identity mapping, got " + inputMapping);
    }

    TableModificationRel newModifier = modifier;
    if (newInput != input) {
      newModifier = modifier.copy(modifier.getTraitSet(), Collections.singletonList(newInput));
    }
    assert newModifier.getClass() == modifier.getClass();

    // Always project all fields.
    Mapping mapping = Mappings.createIdentity(fieldCount);
    return new TrimResult(newModifier, mapping);
  }
Пример #3
0
 /**
  * Trims the fields of an input relational expression.
  *
  * @param rel Relational expression
  * @param input Input relational expression, whose fields to trim
  * @param fieldsUsed Bitmap of fields needed by the consumer
  * @return New relational expression and its field mapping
  */
 protected TrimResult trimChild(
     RelNode rel, RelNode input, BitSet fieldsUsed, Set<RelDataTypeField> extraFields) {
   Util.discard(rel);
   if (input.getClass().getName().endsWith("MedMdrClassExtentRel")) {
     // MedMdrJoinRule cannot handle Join of Project of
     // MedMdrClassExtentRel, only naked MedMdrClassExtentRel.
     // So, disable trimming.
     fieldsUsed = Util.bitSetBetween(0, input.getRowType().getFieldCount());
   }
   return dispatchTrimFields(input, fieldsUsed, extraFields);
 }
Пример #4
0
 /**
  * Records the fact that instances of <code>rel</code> are available via <code>bind</code> (which
  * may be eager or lazy).
  */
 private void bind(RelNode rel, Bind bind) {
   tracer.log(Level.FINE, "Bind " + rel.toString() + " to " + bind);
   JavaFrame frame = (JavaFrame) mapRel2Frame.get(rel);
   frame.bind = bind;
   boolean stupid = SaffronProperties.instance().stupid.get();
   if (stupid) {
     // trigger the declaration of the variable, even though it
     // may not be used
     Util.discard(bind.getVariable());
   }
 }
Пример #5
0
 @Test
 public void testFilterSort() {
   // LONGITUDE and LATITUDE are null because of OPTIQ-194.
   Util.discard(Bug.OPTIQ_194_FIXED);
   OptiqAssert.that()
       .enable(enabled())
       .with(ZIPS)
       .query(
           "select * from zips\n"
               + "where city = 'SPRINGFIELD' and id between '20000' and '30000'\n"
               + "order by state")
       .returns(
           "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=2184; STATE=SC; ID=29146\n"
               + "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=16811; STATE=VA; ID=22150\n"
               + "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=32161; STATE=VA; ID=22153\n"
               + "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=1321; STATE=WV; ID=26763\n")
       .queryContains(
           mongoChecker(
               "{\n"
                   + "  $match: {\n"
                   + "    city: \"SPRINGFIELD\",\n"
                   + "    _id: {\n"
                   + "      $lte: \"30000\",\n"
                   + "      $gte: \"20000\"\n"
                   + "    }\n"
                   + "  }\n"
                   + "}",
               "{$project: {CITY: '$city', LONGITUDE: '$loc[0]', LATITUDE: '$loc[1]', POP: '$pop', STATE: '$state', ID: '$_id'}}",
               "{$sort: {STATE: 1}}"))
       .explainContains(
           "PLAN=MongoToEnumerableConverter\n"
               + "  MongoSortRel(sort0=[$4], dir0=[ASC])\n"
               + "    MongoProjectRel(CITY=[CAST(ITEM($0, 'city')):VARCHAR(20) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"], LONGITUDE=[CAST(ITEM(ITEM($0, 'loc'), 0)):FLOAT NOT NULL], LATITUDE=[CAST(ITEM(ITEM($0, 'loc'), 1)):FLOAT NOT NULL], POP=[CAST(ITEM($0, 'pop')):INTEGER], STATE=[CAST(ITEM($0, 'state')):VARCHAR(2) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"], ID=[CAST(ITEM($0, '_id')):VARCHAR(5) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"])\n"
               + "      MongoFilterRel(condition=[AND(=(CAST(ITEM($0, 'city')):VARCHAR(20) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", 'SPRINGFIELD'), >=(CAST(ITEM($0, '_id')):VARCHAR(5) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", '20000'), <=(CAST(ITEM($0, '_id')):VARCHAR(5) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", '30000'))])\n"
               + "        MongoTableScan(table=[[mongo_raw, zips]])");
 }
Пример #6
0
 SubExprExistsException(RexNode expr) {
   Util.discard(expr);
 }
 public String getSignatureTemplate(int operandsCount) {
   Util.discard(operandsCount);
   return "{0}({1} FROM {2})";
 }
Пример #8
0
 /**
  * Creates a RelFieldTrimmer.
  *
  * @param validator Validator
  */
 public RelFieldTrimmer(SqlValidator validator) {
   Util.discard(validator); // may be useful one day
   this.trimFieldsDispatcher =
       ReflectUtil.createMethodDispatcher(
           TrimResult.class, this, "trimFields", RelNode.class, BitSet.class, Set.class);
 }
Пример #9
0
 /**
  * Visit method, per {@link org.eigenbase.util.ReflectiveVisitor}.
  *
  * <p>This method is invoked reflectively, so there may not be any apparent calls to it. The class
  * (or derived classes) may contain overloads of this method with more specific types for the
  * {@code rel} parameter.
  *
  * <p>Returns a pair: the relational expression created, and the mapping between the original
  * fields and the fields of the newly created relational expression.
  *
  * @param rel Relational expression
  * @param fieldsUsed Fields needed by the consumer
  * @return relational expression and mapping
  */
 public TrimResult trimFields(RelNode rel, BitSet fieldsUsed, Set<RelDataTypeField> extraFields) {
   // We don't know how to trim this kind of relational expression, so give
   // it back intact.
   Util.discard(fieldsUsed);
   return new TrimResult(rel, Mappings.createIdentity(rel.getRowType().getFieldCount()));
 }
Пример #10
0
 public JdbcImplementor(SqlDialect dialect, JavaTypeFactory typeFactory) {
   this.dialect = dialect;
   Util.discard(typeFactory);
 }
 /**
  * Validates this node in an expression context.
  *
  * <p>Usually, this method does much the same as {@link #validate}, but a {@link SqlIdentifier}
  * can occur in expression and non-expression contexts.
  */
 public void validateExpr(SqlValidator validator, SqlValidatorScope scope) {
   validate(validator, scope);
   Util.discard(validator.deriveType(scope, this));
 }
 public String getSignatureTemplate(final int operandsCount) {
   Util.discard(operandsCount);
   return "{1} {0} {2} AND {3}";
 }