use of org.apache.flink.table.types.DataTypeQueryable in project flink by apache.
the class FieldInfoUtils method getFieldNames.
/**
* Returns field names for a given {@link TypeInformation}. If the input {@link TypeInformation}
* is not a composite type, the result field name should not exist in the existingNames.
*
* @param inputType The TypeInformation extract the field names.
* @param existingNames The existing field names for non-composite types that can not be used.
* @param <A> The type of the TypeInformation.
* @return An array holding the field names
*/
public static <A> String[] getFieldNames(TypeInformation<A> inputType, List<String> existingNames) {
validateInputTypeInfo(inputType);
List<String> fieldNames = null;
// type originated from Table API
if (inputType instanceof DataTypeQueryable) {
final DataType dataType = ((DataTypeQueryable) inputType).getDataType();
final LogicalType type = dataType.getLogicalType();
if (isCompositeType(type)) {
fieldNames = LogicalTypeChecks.getFieldNames(type);
}
} else // type originated from other API
if (inputType instanceof CompositeType) {
fieldNames = Arrays.asList(((CompositeType<A>) inputType).getFieldNames());
}
// atomic in any case
if (fieldNames == null) {
fieldNames = Collections.singletonList(getAtomicName(existingNames));
}
if (fieldNames.contains("*")) {
throw new TableException("Field name can not be '*'.");
}
return fieldNames.toArray(new String[0]);
}
use of org.apache.flink.table.types.DataTypeQueryable in project flink by apache.
the class FieldInfoUtils method isIndexedComposite.
private static boolean isIndexedComposite(TypeInformation<?> inputType) {
// type originated from Table API
if (inputType instanceof DataTypeQueryable) {
final DataType dataType = ((DataTypeQueryable) inputType).getDataType();
final LogicalType type = dataType.getLogicalType();
// every composite in Table API is indexed
return isCompositeType(type);
}
// type originated from other API
return inputType instanceof TupleTypeInfoBase;
}
Aggregations