Class Convert


  • @Experimental(SCHEMAS)
    public class Convert
    extends java.lang.Object
    A set of utilities for converting between different objects supporting schemas.
    • Constructor Detail

      • Convert

        public Convert()
    • Method Detail

      • fromRows

        public static <OutputT> PTransform<PCollection<Row>,​PCollection<OutputT>> fromRows​(java.lang.Class<OutputT> clazz)
        Convert a PCollection<Row> into a PCollection<OutputT>.

        The output schema will be inferred using the schema registry. A schema must be registered for this type, or the conversion will fail.

      • to

        public static <InputT,​OutputT> PTransform<PCollection<InputT>,​PCollection<OutputT>> to​(java.lang.Class<OutputT> clazz)
        Convert a PCollection<InputT> to a PCollection<OutputT>.

        This function allows converting between two types as long as the two types have compatible schemas. Two schemas are said to be compatible if they recursively have fields with the same names, but possibly different orders. If the source schema can be unboxed to match the target schema (i.e. the source schema contains a single field that is compatible with the target schema), then conversion also succeeds.

      • to

        public static <InputT,​OutputT> PTransform<PCollection<InputT>,​PCollection<OutputT>> to​(TypeDescriptor<OutputT> typeDescriptor)
        Convert a PCollection<InputT> to a PCollection<OutputT>.

        This function allows converting between two types as long as the two types have compatible schemas. Two schemas are said to be compatible if they recursively have fields with the same names, but possibly different orders. If the source schema can be unboxed to match the target schema (i.e. the source schema contains a single field that is compatible with the target schema), then conversion also succeeds.