Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
  /**
   * Looks up a field with a given name, returning null if not found.
   *
   * @param rowType Row type
   * @param columnName Field name
   * @return Field, or null if not found
   */
  public static RelDataTypeField lookupField(
      boolean caseSensitive, final RelDataType rowType, String columnName) {
    RelDataTypeField field = rowType.getField(columnName, caseSensitive);
    if (field != null) {
      return field;
    }

    // If record type is flagged as having "any field you ask for",
    // return a type. (TODO: Better way to mark accommodating types.)
    RelDataTypeField extra = RelDataTypeImpl.extra(rowType);
    if (extra != null) {
      return new RelDataTypeFieldImpl(columnName, -1, extra.getType());
    }
    return null;
  }