Exemplo n.º 1
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;
  }
Exemplo n.º 2
0
 /**
  * Creates an inference rule which returns a type with precision but no scale, such as {@code
  * VARCHAR(100)}.
  */
 public static ExplicitReturnTypeInference explicit(SqlTypeName typeName, int precision) {
   return explicit(RelDataTypeImpl.proto(typeName, precision, false));
 }
Exemplo n.º 3
0
 /** Creates an inference rule which returns a copy of a given data type. */
 public static ExplicitReturnTypeInference explicit(RelDataType type) {
   return explicit(RelDataTypeImpl.proto(type));
 }