Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleAvroSchemaUtils
/**
 * A user facing public util class to help converting {@link org.apache.avro.Schema Avro Schemas}
 * to Flink {@link DataType} and {@link Schema Table Schema}.
 */
@PublicEvolving
public class AvroSchemaUtils {

    /** private constructor for util class to prevent instantiation. */
    private AvroSchemaUtils() {}

    /**
     * Converts the given Avro schema string to a Flink {@link DataType}. This is useful
     * when user wants to convert a Table to a DataStream.
     *
     * @param avroSchemaString Avro schema string
     * @return the DataType converted from Avro schema string.
     * @see org.apache.flink.table.api.bridge.java.StreamTableEnvironment#toDataStream(Table, AbstractDataType)
     */
    public static DataType convertToDataType(String avroSchemaString) {
        return AvroSchemaConverter.convertToDataType(avroSchemaString);
    }

    /**
     * Converts the given Avro schema to a Flink {@link DataType}. This is useful
     * when user wants to convert a Table to a DataStream.
     *
     * @param schema Avro schema
     * @return the DataType converted from Avro schema string.
     * @see org.apache.flink.table.api.bridge.java.StreamTableEnvironment#toDataStream(Table, AbstractDataType)
     */
    public static DataType convertToDataType(org.apache.avro.Schema schema) {
        return AvroSchemaConverter.convertToDataType(schema);
    }

    /**
     * Converts the given Avro schema string to a Flink
     * {@link org.apache.flink.table.api.Schema Table Schema}.This is useful when user wants
     * to convert a DataStream into a Table.
     *
     * @param avroSchemaString Avro schema string.
     * @see org.apache.flink.table.api.bridge.java.StreamTableEnvironment#fromDataStream(DataStream, Schema)
     * @return the Table Schema converted from Avro schema string.
     */
    public static Schema convertToTableSchema(String avroSchemaString) {
        return AvroSchemaConverter.convertToTableSchema(avroSchemaString);
    }

    /**
     * Converts the given Avro schema to a Flink
     * {@link org.apache.flink.table.api.Schema Table Schema}.This is useful when user wants
     * to convert a DataStream into a Table.
     *
     * @param schema Avro schema.
     * @see org.apache.flink.table.api.bridge.java.StreamTableEnvironment#fromDataStream(DataStream, Schema)
     * @return the Table Schema converted from Avro schema string.
     */
    public static Schema convertToTableSchema(org.apache.avro.Schema schema) {
        return AvroSchemaConverter.convertToTableSchema(schema);
    }
}

...