Java Code Examples for org.apache.flink.table.utils.TypeStringUtils#readTypeInfo()

The following examples show how to use org.apache.flink.table.utils.TypeStringUtils#readTypeInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogicalTypeParser.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private LogicalType parseLegacyType() {
	nextToken(TokenType.BEGIN_PARAMETER);
	nextToken(TokenType.LITERAL_STRING);
	final String rootString = tokenAsString();

	nextToken(TokenType.LIST_SEPARATOR);
	nextToken(TokenType.LITERAL_STRING);
	final String typeInfoString = tokenAsString();
	nextToken(TokenType.END_PARAMETER);

	try {
		final LogicalTypeRoot root = LogicalTypeRoot.valueOf(rootString);
		final TypeInformation typeInfo = TypeStringUtils.readTypeInfo(typeInfoString);
		return new LegacyTypeInformationType<>(root, typeInfo);
	} catch (Throwable t) {
		throw parsingError(
				"Unable to restore the Legacy type of '" + typeInfoString + "' with " +
						"type root '" + rootString + "'.", t);
	}
}
 
Example 2
Source File: FeatureBorder.java    From Alink with Apache License 2.0 4 votes vote down vote up
public static TypeInformation<?> getFlinkType(String typeStr) {
    if ("STRING".equals(typeStr)) {
        typeStr = "VARCHAR";
    }
    return TypeStringUtils.readTypeInfo(typeStr);
}
 
Example 3
Source File: Schema.java    From flink with Apache License 2.0 3 votes vote down vote up
/**
 * Adds a field with the field name and the type string. Required.
 * This method can be called multiple times. The call order of this method defines
 * also the order of the fields in a row.
 *
 * <p>NOTE: the fieldType string should follow the type string defined in {@link LogicalTypeParser}.
 * This method also keeps compatible with old type string defined in {@link TypeStringUtils}
 * but will be dropped in future versions as it uses the old type system.
 *
 * @param fieldName the field name
 * @param fieldType the type string of the field
 */
public Schema field(String fieldName, String fieldType) {
	if (isLegacyTypeString(fieldType)) {
		// fallback to legacy parser
		TypeInformation<?> typeInfo = TypeStringUtils.readTypeInfo(fieldType);
		return field(fieldName, TypeConversions.fromLegacyInfoToDataType(typeInfo));
	} else {
		return addField(fieldName, fieldType);
	}
}
 
Example 4
Source File: OldCsv.java    From flink with Apache License 2.0 3 votes vote down vote up
/**
 * Adds a format field with the field name and the type string. Required.
 * This method can be called multiple times. The call order of this method defines
 * also the order of the fields in the format.
 *
 * <p>NOTE: the fieldType string should follow the type string defined in {@link LogicalTypeParser}.
 * This method also keeps compatible with old type string defined in {@link TypeStringUtils} but
 * will be dropped in future versions as it uses the old type system.
 *
 * @param fieldName the field name
 * @param fieldType the type string of the field
 * @deprecated {@link OldCsv} supports derive schema from table schema by default,
 *             it is no longer necessary to explicitly declare the format schema.
 *             This method will be removed in the future.
 */
@Deprecated
public OldCsv field(String fieldName, String fieldType) {
	if (isLegacyTypeString(fieldType)) {
		// fallback to legacy parser
		TypeInformation<?> typeInfo = TypeStringUtils.readTypeInfo(fieldType);
		return field(fieldName, TypeConversions.fromLegacyInfoToDataType(typeInfo));
	} else {
		return addField(fieldName, fieldType);
	}
}
 
Example 5
Source File: TypeUtils.java    From alchemy with Apache License 2.0 2 votes vote down vote up
public static TypeInformation readTypeInfo(String typeString){

        return TypeStringUtils.readTypeInfo(typeString);
    }
 
Example 6
Source File: FlinkTypeConverter.java    From Alink with Apache License 2.0 2 votes vote down vote up
/**
 * Convert string representation to flink TypeInformation.
 *
 * @param typeSQL string representation of type
 * @return flink TypeInformation
 */
public static TypeInformation<?> getFlinkType(String typeSQL) {
    return TypeStringUtils.readTypeInfo(typeSQL);
}