예제 #1
0
 // implement RelDataType
 public RelDataTypeField getField(String fieldName, boolean caseSensitive) {
   for (RelDataTypeField field : fieldList) {
     if (Util.match(caseSensitive, field.getName(), fieldName)) {
       return field;
     }
   }
   // Extra field
   if (fieldList.size() > 0) {
     final RelDataTypeField lastField = Iterables.getLast(fieldList);
     if (lastField.getName().equals("_extra")) {
       return new RelDataTypeFieldImpl(fieldName, -1, lastField.getType());
     }
   }
   return null;
 }
예제 #2
0
  private static List<RelCollation> deduceMonotonicity(Prepare.PreparingTable table) {
    final List<RelCollation> collationList = new ArrayList<RelCollation>();

    // Deduce which fields the table is sorted on.
    int i = -1;
    for (RelDataTypeField field : table.getRowType().getFieldList()) {
      ++i;
      final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName());
      if (monotonicity != SqlMonotonicity.NotMonotonic) {
        final RelFieldCollation.Direction direction =
            monotonicity.isDecreasing()
                ? RelFieldCollation.Direction.Descending
                : RelFieldCollation.Direction.Ascending;
        collationList.add(
            RelCollationImpl.of(
                new RelFieldCollation(i, direction, RelFieldCollation.NullDirection.UNSPECIFIED)));
      }
    }
    return collationList;
  }
예제 #3
0
    private List<RelCollation> deduceMonotonicity(SqlValidatorTable table) {
      final RelDataType rowType = table.getRowType();
      final List<RelCollation> collationList = new ArrayList<RelCollation>();

      // Deduce which fields the table is sorted on.
      int i = -1;
      for (RelDataTypeField field : rowType.getFieldList()) {
        ++i;
        final SqlMonotonicity monotonicity = table.getMonotonicity(field.getName());
        if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) {
          final RelFieldCollation.Direction direction =
              monotonicity.isDecreasing()
                  ? RelFieldCollation.Direction.DESCENDING
                  : RelFieldCollation.Direction.ASCENDING;
          collationList.add(
              RelCollationImpl.of(
                  new RelFieldCollation(
                      i, direction, RelFieldCollation.NullDirection.UNSPECIFIED)));
        }
      }
      return collationList;
    }